<div id="cnblogs_post_body" class="blogpost-body"><p><span style="font-family: 幼圓">本篇文章是對H+這種框架進行整理,順便了解一下標準的代碼規範的寫法。</span></p> <p><strong><span style="font-family: 幼圓; font-size: 16px">1、表單:</span></strong></p> <p><span style="font-size: 16px"><strong><span style="font-family: 幼圓">1)、下面是一個基本表單:</span></strong></span></p> <p><span style="font-family: 幼圓"><img src="https://images2015.cnblogs.com/blog/1055766/201704/1055766-20170407095129644-525659583.png" alt=""></span></p> <p><span style="font-family: 幼圓; font-size: 15px">如今來看這個表單的結構:</span></p> <p><span style="font-family: 幼圓; font-size: 15px"><span style="font-size: 16px"><strong>1.</strong></span>整個表單的外框結構是一個div,至於padding和margin,則須要你們根據實際項目的狀況來設定。</span></p> <p><span style="font-family: 幼圓"><img src="https://images2015.cnblogs.com/blog/1055766/201704/1055766-20170407102634128-1002696269.png" alt=""></span></p> <p><strong><span style="font-size: 16px">2.</span></strong><span style="font-size: 16px; font-family: 幼圓"><span style="font-size: 15px">div裏面的第二部分先須要用<form></form>標籤包裹,裏面的每個紅色框都是一個form-group.</span></span></p> <p><img src="https://images2015.cnblogs.com/blog/1055766/201704/1055766-20170407103001285-961994313.png" alt=""></p> <p><span style="font-size: 16px"><strong>3.</strong><span style="font-family: 幼圓; font-size: 15px">在每個form-group裏面,用label標籤將標籤頭如「用戶名,密碼」等包裹起來。</span></span></p> <p><img src="https://images2015.cnblogs.com/blog/1055766/201704/1055766-20170407104148738-783424062.png" alt=""></p> <p><span style="font-size: 16px"><strong>4.</strong></span><span style="font-family: 幼圓; font-size: 15px">自動登陸和登陸按鈕的那裏,一個左浮,一個右浮,對於自動登陸。外面用label套住整個。而後是div裏面裝有input,而後是自動登陸文字。</span></p> <p><span style="font-family: 幼圓; font-size: 15px"><img src="https://images2015.cnblogs.com/blog/1055766/201704/1055766-20170407105348582-1397217081.png" alt=""></span></p> <p>框架大體代碼以下:</p> <div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="複製代碼"><img src="//common.cnblogs.com/images/copycode.gif" alt="複製代碼"></a></span></div> <pre><div> <h3>登陸</h3> <p>歡迎登陸本站(⊙o⊙)</p> <form role=<span style="color: #800000">"</span><span style="color: #800000">form</span><span style="color: #800000">"</span>> <div <span style="color: #0000ff">class</span>=<span style="color: #800000">"</span><span style="color: #800000">form-group</span><span style="color: #800000">"</span>> <label>用戶名</label> <input placeholder=<span style="color: #800000">"</span><span style="color: #800000">請輸入您註冊的E-mail</span><span style="color: #800000">"</span> <span style="color: #0000ff">class</span>=<span style="color: #800000">"</span><span style="color: #800000">form-control</span><span style="color: #800000">"</span> type=<span style="color: #800000">"</span><span style="color: #800000">email</span><span style="color: #800000">"</span>> </div> <div <span style="color: #0000ff">class</span>=<span style="color: #800000">"</span><span style="color: #800000">form-group</span><span style="color: #800000">"</span>> <label>密碼</label> <input placeholder=<span style="color: #800000">"</span><span style="color: #800000">請輸入密碼</span><span style="color: #800000">"</span> <span style="color: #0000ff">class</span>=<span style="color: #800000">"</span><span style="color: #800000">form-control</span><span style="color: #800000">"</span> type=<span style="color: #800000">"</span><span style="color: #800000">password</span><span style="color: #800000">"</span>> </div> <div> <button <span style="color: #0000ff">class</span>=<span style="color: #800000">"</span><span style="color: #800000">btn btn-sm btn-primary pull-right m-t-n-xs</span><span style="color: #800000">"</span> type=<span style="color: #800000">"</span><span style="color: #800000">submit</span><span style="color: #800000">"</span>><br> <strong>登 錄</strong> </button> <label> <div><br> <input type=<span style="color: #800000">"</span><span style="color: #800000">checkbox</span><span style="color: #800000">"</span>><br> </div><br> 自動登陸<br> </label> </div> </form> </div></pre> <div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="複製代碼"><img src="//common.cnblogs.com/images/copycode.gif" alt="複製代碼"></a></span></div></div> <p><span style="font-size: 16px"><strong><span style="font-family: 幼圓">2)、下面是一個橫向表單:</span></strong></span></p> <p> <img src="https://images2015.cnblogs.com/blog/1055766/201704/1055766-20170407111014300-1471563540.png" alt=""></p> <p>下面是橫向表單的部分代碼:</p> <div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="複製代碼"><img src="//common.cnblogs.com/images/copycode.gif" alt="複製代碼"></a></span></div> <pre><span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="form-group"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">label </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="col-sm-3 control-label"</span><span style="color: #0000ff">></span>用戶名:<span style="color: #0000ff"></</span><span style="color: #800000">label</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="col-sm-8"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">input </span><span style="color: #ff0000">placeholder</span><span style="color: #0000ff">="用戶名"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="form-control"</span><span style="color: #ff0000"> type</span><span style="color: #0000ff">="email"</span><span style="color: #0000ff">></span> <br><span style="color: #0000ff"> <</span><span style="color: #800000">span </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="help-block m-b-none"</span><span style="color: #0000ff">></span>請輸入您註冊時所填的E-mail<span style="color: #0000ff"></</span><span style="color: #800000">span</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre> <div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="複製代碼"><img src="//common.cnblogs.com/images/copycode.gif" alt="複製代碼"></a></span></div></div> <p>相對應的部分重要css以下:</p> <div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="複製代碼"><img src="//common.cnblogs.com/images/copycode.gif" alt="複製代碼"></a></span></div> <pre><span style="color: #800000">.control-label</span>{<span style="color: #ff0000"> padding-top</span>:<span style="color: #0000ff"> 7px</span>;<span style="color: #ff0000"> margin-bottom</span>:<span style="color: #0000ff"> 0</span>;<span style="color: #ff0000"> text-align</span>:<span style="color: #0000ff"> right</span>;}//這行重要<span style="color: #800000"> .form-control</span>{<span style="color: #ff0000"> background-color</span>:<span style="color: #0000ff"> #FFF</span>;<span style="color: #ff0000"> border</span>:<span style="color: #0000ff"> 1px solid #e5e6e7</span>;<span style="color: #ff0000"> border-radius</span>:<span style="color: #0000ff"> 1px</span>;<span style="color: #ff0000"> display</span>:<span style="color: #0000ff"> block</span>;<span style="color: #ff0000"> padding</span>:<span style="color: #0000ff"> 6px 12px</span>;<span style="color: #ff0000"> transition</span>:<span style="color: #0000ff"> border-color 2s ease-in-out 0s,box-shadow .15s ease-in-out 0s</span>;//這行重要<span style="color: #ff0000"> width</span>:<span style="color: #0000ff"> 100%</span>;<span style="color: #ff0000"> font-size</span>:<span style="color: #0000ff"> 14px</span>;}<span style="color: #800000"> .help-block </span>{<span style="color: #ff0000"> display</span>:<span style="color: #0000ff"> block</span>;//這行重要<span style="color: #ff0000"> margin-top</span>:<span style="color: #0000ff"> 5px</span>;<span style="color: #ff0000"> margin-bottom</span>:<span style="color: #0000ff"> 10px</span>;<span style="color: #ff0000"> color</span>:<span style="color: #0000ff"> #737373</span>;</pre> <div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="複製代碼"><img src="//common.cnblogs.com/images/copycode.gif" alt="複製代碼"></a></span></div></div> <p><span style="font-size: 16px"><strong><span style="font-family: 幼圓">3)、下面是一個彈出表單:</span></strong></span></p> <p><span style="font-size: 15px"><span style="font-family: 幼圓">這是按鈕以及彈出後的效果:</span></span></p> <p><span style="font-size: 15px"><span style="font-family: 幼圓">按鈕:</span></span></p> <p> <img src="https://images2015.cnblogs.com/blog/1055766/201704/1055766-20170407112705628-243875104.png" alt=""></p> <p>效果:</p> <p><img src="https://images2015.cnblogs.com/blog/1055766/201704/1055766-20170407112829238-547007376.png" alt=""></p> <p>下面是按鈕代碼:因爲按鈕的css都是一些簡單樣式類,故此處再也不贅述。</p> <div class="cnblogs_code"> <pre><span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="text-center"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">a </span><span style="color: #ff0000">data-toggle</span><span style="color: #0000ff">="modal"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="btn btn-primary"</span><span style="color: #ff0000"> href</span><span style="color: #0000ff">="form_basic.html#modal-form"</span><span style="color: #0000ff">></span>打開登陸窗口<span style="color: #0000ff"></</span><span style="color: #800000">a</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre> </div> <p>下面是modal彈出後代碼:</p> <div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="複製代碼"><img src="//common.cnblogs.com/images/copycode.gif" alt="複製代碼"></a></span></div> <pre><span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="modal-form"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="modal fade in"</span><span style="color: #ff0000"> aria-hidden</span><span style="color: #0000ff">="true"</span><span style="color: #ff0000"> style</span><span style="color: #0000ff">="display: block; padding-right: 17px;"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="modal-dialog"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="modal-content"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="modal-body"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="row"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="col-sm-6 b-r"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">h3 </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="m-t-none m-b"</span><span style="color: #0000ff">></span>登陸<span style="color: #0000ff"></</span><span style="color: #800000">h3</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">p</span><span style="color: #0000ff">></span>歡迎登陸本站(⊙o⊙)<span style="color: #0000ff"></</span><span style="color: #800000">p</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">form </span><span style="color: #ff0000">role</span><span style="color: #0000ff">="form"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="form-group"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">label</span><span style="color: #0000ff">></span>用戶名:<span style="color: #0000ff"></</span><span style="color: #800000">label</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">input </span><span style="color: #ff0000">placeholder</span><span style="color: #0000ff">="請輸入用戶名"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="form-control"</span><span style="color: #ff0000"> type</span><span style="color: #0000ff">="email"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="form-group"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">label</span><span style="color: #0000ff">></span>密碼:<span style="color: #0000ff"></</span><span style="color: #800000">label</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">input </span><span style="color: #ff0000">placeholder</span><span style="color: #0000ff">="請輸入密碼"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="form-control"</span><span style="color: #ff0000"> type</span><span style="color: #0000ff">="password"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">div</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">button </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="btn btn-sm btn-primary pull-right m-t-n-xs"</span><span style="color: #ff0000"> type</span><span style="color: #0000ff">="submit"</span><span style="color: #0000ff">><</span><span style="color: #800000">strong</span><span style="color: #0000ff">></span>登陸<span style="color: #0000ff"></</span><span style="color: #800000">strong</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">button</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">label </span><span style="color: #ff0000">class</span><span style="color: #0000ff">=""</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="icheckbox_square-green"</span><span style="color: #ff0000"> style</span><span style="color: #0000ff">="position: relative;"</span><span style="color: #0000ff">><</span><span style="color: #800000">input </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="i-checks"</span><span style="color: #ff0000"> style</span><span style="color: #0000ff">="position: absolute; opacity: 0;"</span><span style="color: #ff0000"> type</span><span style="color: #0000ff">="checkbox"</span><span style="color: #0000ff">><</span><span style="color: #800000">ins </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="iCheck-helper"</span><span style="color: #ff0000"> style</span><span style="color: #0000ff">="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"</span><span style="color: #0000ff">></</span><span style="color: #800000">ins</span><span style="color: #0000ff">></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span>自動登陸<span style="color: #0000ff"></</span><span style="color: #800000">label</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">form</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="col-sm-6"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">h4</span><span style="color: #0000ff">></span>還不是會員?<span style="color: #0000ff"></</span><span style="color: #800000">h4</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">p</span><span style="color: #0000ff">></span>您能夠註冊一個帳戶<span style="color: #0000ff"></</span><span style="color: #800000">p</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">p </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="text-center"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">a </span><span style="color: #ff0000">href</span><span style="color: #0000ff">="form_basic.html"</span><span style="color: #0000ff">><</span><span style="color: #800000">i </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="fa fa-sign-in big-icon"</span><span style="color: #0000ff">></</span><span style="color: #800000">i</span><span style="color: #0000ff">></</span><span style="color: #800000">a</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">p</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span></pre> <div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="複製代碼"><img src="//common.cnblogs.com/images/copycode.gif" alt="複製代碼"></a></span></div></div> <p>modal框css:</p> <p>一、#modal-form 的css,能夠看到,幾乎都是系統自帶:</p> <p><img src="https://images2015.cnblogs.com/blog/1055766/201704/1055766-20170407113622410-120582232.png" alt=""></p> <p>二、.<span style="color: #0000ff">modal-dialog樣式:能夠看到,也幾乎都是系統自帶:</span></p> <p><span style="color: #0000ff"><img src="https://images2015.cnblogs.com/blog/1055766/201704/1055766-20170407113741878-775192798.png" alt=""></span></p> <p> </p></div>javascript