溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

bootstrap中怎么實(shí)現(xiàn)表單居中顯示

發(fā)布時(shí)間:2021-07-26 11:40:53 來源:億速云 閱讀:1245 作者:Leah 欄目:開發(fā)技術(shù)

本篇文章為大家展示了bootstrap中怎么實(shí)現(xiàn)表單居中顯示,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。

Bootstrap通過一些簡單的 HTML 標(biāo)簽和擴(kuò)展的類即可創(chuàng)建出不同樣式的表單。

Bootstrap提供了多種表單布局,不過我們最常用的就是表單居中,也叫水平表單。

水平表單與其他表單不僅標(biāo)記的數(shù)量上不同,而且表單的呈現(xiàn)形式也不同。

如需創(chuàng)建一個(gè)水平布局的表單,請按下面的幾個(gè)步驟進(jìn)行:

向父 <form> 元素添加 class .form-horizontal。

把標(biāo)簽和控件放在一個(gè)帶有 class .form-group 的 <div> 中。

向標(biāo)簽添加 class .control-label。

實(shí)例:

<!DOCTYPE html><html><head><meta charset="utf-8"> <title>Bootstrap 實(shí)例 - 水平表單</title><link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script><script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script></head><body><form class="form-horizontal" role="form"><div class="form-group"><label for="firstname" class="col-sm-2 control-label">名字</label><div class="col-sm-10"><input type="text" class="form-control" id="firstname"    placeholder="請輸入名字"></div></div><div class="form-group"><label for="lastname" class="col-sm-2 control-label">姓</label><div class="col-sm-10"><input type="text" class="form-control" id="lastname"    placeholder="請輸入姓"></div></div><div class="form-group"><div class="col-sm-offset-2 col-sm-10"><div class="checkbox"><label><input type="checkbox"> 請記住我</label></div></div></div><div class="form-group"><div class="col-sm-offset-2 col-sm-10"><button type="submit" class="btn btn-default">登錄</button></div></div></form></body></html>

上述內(nèi)容就是bootstrap中怎么實(shí)現(xiàn)表單居中顯示,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI