bootstrap css樣式之表單
本文實例為大家分享了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實現(xiàn)Form表單驗證
- JS組件Form表單驗證神器BootstrapValidator
- 全面解析Bootstrap表單使用方法(表單按鈕)
- Bootstrap實現(xiàn)登錄校驗表單(帶驗證碼)
- 全面解析Bootstrap表單使用方法(表單樣式)
- 實用又漂亮的BootstrapValidator表單驗證插件
- 基于bootstrap插件實現(xiàn)autocomplete自動完成表單
- Bootstrap每天必學(xué)之表單
- Bootstrap導(dǎo)航欄各元素操作方法(表單、按鈕、文本)
- 全面解析Bootstrap表單使用方法(表單控件)
相關(guān)文章
深入淺析JavaScript中對事件的三種監(jiān)聽方式
最近這段時間因為每天要修改網(wǎng)站,為網(wǎng)站做特效,所以看了很多的js接觸事件,自己只會使用一小部分,有時用的時候也比較混亂,現(xiàn)在系統(tǒng)的整理了一下,本篇文章跟大家分享的是JavaScript中對事件的三種監(jiān)聽方式2015-09-09微信小程序web-view不支持打開非業(yè)務(wù)域名https?//XXXX?請重新配置的解決辦法
小程序現(xiàn)在日漸成熟,功能也越來越強大,我們今天來一起看看小程序跳轉(zhuǎn)H5頁面的問題,下面這篇文章主要給大家介紹了關(guān)于微信小程序web-view不支持打開非業(yè)務(wù)域名https?//XXXX?請重新配置的解決辦法,需要的朋友可以參考下2022-08-08基于JS實現(xiàn)發(fā)送短信驗證碼后的倒計時功能(無視頁面刷新,頁面關(guān)閉不進(jìn)行倒計時功能)
這篇文章主要介紹了基于JS實現(xiàn)發(fā)送短信驗證碼后的倒計時功能(無視頁面刷新,頁面關(guān)閉不進(jìn)行倒計時功能)的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-09-09信息頁文內(nèi)畫中畫廣告js實現(xiàn)代碼(文中加載廣告方式)
一般來說文章內(nèi)容中的廣告點擊率更好,也更容易被訪客看到,如果直接將廣告放到頁面頭部會影響網(wǎng)站的速度,所以一般都比較喜歡這種方法,這里分享下實現(xiàn)方法2016-01-01分享一個自定義的console類 讓你不再糾結(jié)JS中的調(diào)試代碼的兼容
在寫JS的過程中,為了調(diào)試我們常常會寫很多 console.log、console.info、console.group、console.warn、console.error代碼來查看JS的運行情況,但發(fā)布時又因為IE不支持console,又要去掉這些代碼,一不小心就會出錯2012-04-04