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 類(lèi)可使其內(nèi)容左對(duì)齊并且表現(xiàn)為 inline-block 級(jí)別的控件。只適用于視口(viewport)至少在 768px 寬度時(shí)(視口寬度再小的話(huà)就會(huì)使表單折疊)。
一定要添加 label 標(biāo)簽
如果你沒(méi)有為每個(gè)輸入控件設(shè)置 label 標(biāo)簽,屏幕閱讀器將無(wú)法正確識(shí)別。對(duì)于這些內(nèi)聯(lián)表單,你可以通過(guò)為 label 設(shè)置 .sr-only 類(lèi)將其隱藏。
<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、水平排列的表單
通過(guò)為表單添加 .form-horizontal 類(lèi),并聯(lián)合使用 Bootstrap 預(yù)置的柵格類(lèi),可以將 label 標(biāo)簽和控件組水平并排布局。這樣做將改變 .form-group 的行為,使其表現(xiàn)為柵格系統(tǒng)中的行(row),因此就無(wú)需再額外添加 .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>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(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自動(dòng)完成表單
- Bootstrap每天必學(xué)之表單
- Bootstrap導(dǎo)航欄各元素操作方法(表單、按鈕、文本)
- 全面解析Bootstrap表單使用方法(表單控件)
相關(guān)文章
深入淺析JavaScript中對(duì)事件的三種監(jiān)聽(tīng)方式
最近這段時(shí)間因?yàn)槊刻煲薷木W(wǎng)站,為網(wǎng)站做特效,所以看了很多的js接觸事件,自己只會(huì)使用一小部分,有時(shí)用的時(shí)候也比較混亂,現(xiàn)在系統(tǒng)的整理了一下,本篇文章跟大家分享的是JavaScript中對(duì)事件的三種監(jiān)聽(tīng)方式2015-09-09JavaScript實(shí)現(xiàn)獲取本機(jī)IP地址
這篇文章主要介紹了JavaScript實(shí)現(xiàn)獲取本機(jī)IP地址方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-07-07圖片翻轉(zhuǎn)效果具體實(shí)現(xiàn)代碼
想必大家對(duì)圖片翻轉(zhuǎn)效果都有所了解吧,其實(shí)很容易實(shí)現(xiàn)的,下面有個(gè)不錯(cuò)的示例,喜歡的朋友可以參考下2014-01-01微信小程序web-view不支持打開(kāi)非業(yè)務(wù)域名https?//XXXX?請(qǐng)重新配置的解決辦法
小程序現(xiàn)在日漸成熟,功能也越來(lái)越強(qiáng)大,我們今天來(lái)一起看看小程序跳轉(zhuǎn)H5頁(yè)面的問(wèn)題,下面這篇文章主要給大家介紹了關(guān)于微信小程序web-view不支持打開(kāi)非業(yè)務(wù)域名https?//XXXX?請(qǐng)重新配置的解決辦法,需要的朋友可以參考下2022-08-08信息頁(yè)文內(nèi)畫(huà)中畫(huà)廣告js實(shí)現(xiàn)代碼(文中加載廣告方式)
一般來(lái)說(shuō)文章內(nèi)容中的廣告點(diǎn)擊率更好,也更容易被訪(fǎng)客看到,如果直接將廣告放到頁(yè)面頭部會(huì)影響網(wǎng)站的速度,所以一般都比較喜歡這種方法,這里分享下實(shí)現(xiàn)方法2016-01-01分享一個(gè)自定義的console類(lèi) 讓你不再糾結(jié)JS中的調(diào)試代碼的兼容
在寫(xiě)JS的過(guò)程中,為了調(diào)試我們常常會(huì)寫(xiě)很多 console.log、console.info、console.group、console.warn、console.error代碼來(lái)查看JS的運(yùn)行情況,但發(fā)布時(shí)又因?yàn)镮E不支持console,又要去掉這些代碼,一不小心就會(huì)出錯(cuò)2012-04-04