bootstrap css樣式之表單
本文實(shí)例為大家分享了bootstrap表單的具體代碼,供大家參考,具體內(nèi)容如下
1、表單基本用法

<form role="form"> <div class="form-group"> <label for="exampleInputEmail1">Email address</label> <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email"> </div> <div class="form-group"> <label for="exampleInputPassword1">Password</label> <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password"> </div> <div class="form-group"> <label for="exampleInputFile">File input</label> <input type="file" id="exampleInputFile"> <p class="help-block">Example block-level help text here.</p> </div> <div class="checkbox"> <label> <input type="checkbox"> Check me out </label> </div> <button type="submit" class="btn btn-default">Submit</button> </form>
2、內(nèi)聯(lián)表單
為 form 元素添加 .form-inline 類可使其內(nèi)容左對齊并且表現(xiàn)為 inline-block 級別的控件。只適用于視口(viewport)至少在 768px 寬度時(視口寬度再小的話就會使表單折疊)。
一定要添加 label 標(biāo)簽
如果你沒有為每個輸入控件設(shè)置 label 標(biāo)簽,屏幕閱讀器將無法正確識別。對于這些內(nèi)聯(lián)表單,你可以通過為 label 設(shè)置 .sr-only 類將其隱藏。

<form class="form-inline" role="form"> <div class="form-group"> <label class="sr-only" for="exampleInputEmail2">Email address</label> <input type="email" class="form-control" id="exampleInputEmail2" placeholder="Enter email"> </div> <div class="form-group"> <div class="input-group"> <div class="input-group-addon">@</div> <input class="form-control" type="email" placeholder="Enter email"> </div> </div> <div class="form-group"> <label class="sr-only" for="exampleInputPassword2">Password</label> <input type="password" class="form-control" id="exampleInputPassword2" placeholder="Password"> </div> <div class="checkbox"> <label> <input type="checkbox"> Remember me </label> </div> <button type="submit" class="btn btn-default">Sign in</button> </form>
3、水平排列的表單
通過為表單添加 .form-horizontal 類,并聯(lián)合使用 Bootstrap 預(yù)置的柵格類,可以將 label 標(biāo)簽和控件組水平并排布局。這樣做將改變 .form-group 的行為,使其表現(xiàn)為柵格系統(tǒng)中的行(row),因此就無需再額外添加 .row 了。

<form class="form-horizontal" role="form"> <div class="form-group"> <label for="inputEmail3" class="col-sm-2 control-label">Email</label> <div class="col-sm-10"> <input type="email" class="form-control" id="inputEmail3" placeholder="Email"> </div> </div> <div class="form-group"> <label for="inputPassword3" class="col-sm-2 control-label">Password</label> <div class="col-sm-10"> <input type="password" class="form-control" id="inputPassword3" placeholder="Password"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <div class="checkbox"> <label> <input type="checkbox"> Remember me </label> </div> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-default">Sign in</button> </div> </div> </form>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 基于Bootstrap+jQuery.validate實(shí)現(xiàn)Form表單驗(yàn)證
- JS組件Form表單驗(yàn)證神器BootstrapValidator
- 全面解析Bootstrap表單使用方法(表單按鈕)
- Bootstrap實(shí)現(xiàn)登錄校驗(yàn)表單(帶驗(yàn)證碼)
- 全面解析Bootstrap表單使用方法(表單樣式)
- 實(shí)用又漂亮的BootstrapValidator表單驗(yàn)證插件
- 基于bootstrap插件實(shí)現(xiàn)autocomplete自動完成表單
- Bootstrap每天必學(xué)之表單
- Bootstrap導(dǎo)航欄各元素操作方法(表單、按鈕、文本)
- 全面解析Bootstrap表單使用方法(表單控件)
相關(guān)文章
詳解如何解決使用JSON.stringify時遇到的循環(huán)引用問題
這篇文章主要介紹了詳解如何解決使用JSON.stringify時遇到的循環(huán)引用問題,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03
JavaScript 嚴(yán)格模式(use strict)用法實(shí)例分析
這篇文章主要介紹了JavaScript 嚴(yán)格模式(use strict)用法,結(jié)合實(shí)例形式分析了JavaScript 嚴(yán)格模式的基本功能、用法及操作注意事項,需要的朋友可以參考下2020-03-03
javascript html5搖一搖功能的實(shí)現(xiàn)
這篇文章主要為大家詳細(xì)介紹了javascript html5搖一搖功能的實(shí)現(xiàn)過程,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-04-04
js重寫alert控件(適合學(xué)習(xí)js的新手朋友)
這篇文章主要介紹js重寫alert控件的過程比較適合學(xué)習(xí)js的新手朋友,需要的朋友可以參考下2014-08-08
基于JavaScript實(shí)現(xiàn)Json數(shù)據(jù)根據(jù)某個字段進(jìn)行排序
這篇文章主要介紹了基于JavaScript實(shí)現(xiàn)Json數(shù)據(jù)根據(jù)某個字段進(jìn)行排序的相關(guān)資料,需要的朋友可以參考下2015-11-11
Javascript設(shè)計模式之觀察者模式的多個實(shí)現(xiàn)版本實(shí)例
這篇文章主要介紹了Javascript設(shè)計模式之觀察者模式的多個實(shí)現(xiàn)版本實(shí)例,本文給出3種實(shí)現(xiàn)版本代碼,同時給出了Jquery實(shí)現(xiàn)版本,需要的朋友可以參考下2015-03-03
javascript設(shè)計模式 – 備忘錄模式原理與用法實(shí)例分析
這篇文章主要介紹了javascript設(shè)計模式 – 備忘錄模式,結(jié)合實(shí)例形式分析了javascript備忘錄模式相關(guān)概念、原理、用法及操作注意事項,需要的朋友可以參考下2020-04-04

