第四章之BootStrap表單與圖片
Bootstrap,來(lái)自 Twitter,是目前最受歡迎的前端框架。Bootstrap 是基于 HTML、CSS、JAVASCRIPT 的,它簡(jiǎn)潔靈活,使得 Web 開發(fā)更加快捷。
學(xué)習(xí)要點(diǎn):
1.表單
2.圖片
本節(jié)課我們主要學(xué)習(xí)一下 Bootstrap 表單和圖片功能,通過(guò)內(nèi)置的 CSS 定義,顯示各種豐富的效果。
一.表單
Bootstrap 提供了一些豐富的表單樣式供開發(fā)者使用。
1.基本格式
//實(shí)現(xiàn)基本的表單樣式 <form> <div class="form-group"> <label>電子郵件</label> <input type="email" class="form-control" placeholder="請(qǐng)輸入您的電子郵件"> </div> <div class="form-group"> <label>密碼</label> <input type="password" class="form-control" placeholder="請(qǐng)輸入您的密碼"> </div> </form>
注:只有正確設(shè)置了輸入框的 type 類型,才能被賦予正確的樣式。支持的輸入框控件包括:text、password、datetime、datetime-local、date、month、time、week、number、email、url、search、tel 和 color。
2.內(nèi)聯(lián)表單
//讓表單左對(duì)齊浮動(dòng),并表現(xiàn)為 inline-block 內(nèi)聯(lián)塊結(jié)構(gòu) <form class="form-inline">
注:當(dāng)小于 768px,會(huì)恢復(fù)獨(dú)占樣式
3.表單合組
//前后增加片段 <div class="input-group"> <div class="input-group-addon">¥</div> <input type="text" class="form-control"> <div class="input-group-addon">.00</div> </div>
4.水平排列
//讓表單內(nèi)的元素保持水平排列 <form class="form-horizontal"> <div class="form-group"> <label class="col-sm-2 control-label">電子郵件</label> <div class="col-sm-10"> <input type="email" class="form-control" placeholder="請(qǐng)輸入您的電子郵件"> </div> </div> </form>
注:這里用到了 col-sm 柵格系統(tǒng),后面章節(jié)會(huì)重點(diǎn)講解,而 control-label 表示和父元素樣式同步。
5.復(fù)選框和單選框
//設(shè)置復(fù)選框,在一行 <div class="checkbox"> <label> <input type="checkbox">體育 </label> </div> <div class="checkbox"> <label> <input type="checkbox">音樂(lè) </label> </div> //設(shè)置禁用的復(fù)選框 <div class="checkbox disabled"> <label> <input type="checkbox" disabled>音樂(lè) </label> </div> //設(shè)置內(nèi)聯(lián)一行顯示的復(fù)選框 <label class="checkbox-inline"> <input type="checkbox">體育</label> <label class="checkbox-inline disabled"> <input type="checkbox" disabled>音樂(lè)</label> //設(shè)置單選框 <div class="radio disabled"> <label> <input type="radio" name="sex" disabled>男</label> </div>
6.下拉列表
//設(shè)置下拉列表 <select class="form-control"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select>
7.校驗(yàn)狀態(tài)
//設(shè)置為錯(cuò)誤狀態(tài) <div class="form-group has-error">
注:還有其他狀態(tài)如下:
樣式說(shuō)明 has-error錯(cuò)誤狀態(tài) has-success成功狀態(tài) has-warning警告狀態(tài) //label 標(biāo)簽同步相應(yīng)狀態(tài) <label class="control-label">Input with success</label>
8.添加額外的圖標(biāo)
//文本框右側(cè)內(nèi)置文本圖標(biāo) <div class="form-group has-feedback"> <label>電子郵件</label> <input type="email" class="form-control"> <span class="glyphicon glyphicon-ok form-control-feedback"></span> </div>
注:除了 glyphicon-ok 外,還有幾個(gè)如下表:
樣式說(shuō)明 glyphicon-ok成功狀態(tài) glyphicon-warning-sign警告狀態(tài) glyphicon-remove錯(cuò)誤狀態(tài)
9.控制尺寸
//從大到小 <input type="password" class="form-control input-lg"> <input type="password" class="form-control"> <input type="password" class="form-control input-sm">
注:也可以設(shè)置父元素 form-group-lg、form-group-sm,來(lái)調(diào)整。
二.圖片
Bootstrap 提供了一些豐富的圖片樣式供開發(fā)者使用。
1.圖片形狀
//三種形狀 <img src="img/pic.png" alt="圖片" class="img-rounded"> <img src="img/pic.png" alt="圖片" class="img-circle"> <img src="img/pic.png" alt="圖片" class="img-thumbnail"> //響應(yīng)式圖片 <img src="img/pic.png" alt="圖片" class="img-responsive">
以上所述是小編給大家介紹的Bootstrap表單與圖片的相關(guān)內(nèi)容,希望對(duì)大家有所幫助!
- 基于bootstrap插件實(shí)現(xiàn)autocomplete自動(dòng)完成表單
- Bootstrap所支持的表單控件實(shí)例詳解
- 實(shí)用又漂亮的BootstrapValidator表單驗(yàn)證插件
- 基于Bootstrap+jQuery.validate實(shí)現(xiàn)表單驗(yàn)證
- Bootstrap表單布局樣式代碼
- Bootstrap3.0建站教程(一)之bootstrap表單元素排版
- BootStrap智能表單demo示例詳解
- BootStrap 智能表單實(shí)戰(zhàn)系列(二)BootStrap支持的類型簡(jiǎn)介
- BootStrap智能表單實(shí)戰(zhàn)系列(三)分塊表單配置詳解
- BootStrap智能表單實(shí)戰(zhàn)系列(四)表單布局介紹
相關(guān)文章
在Javascript里訪問(wèn)SharePoint列表數(shù)據(jù)的實(shí)現(xiàn)方法
在進(jìn)行SharePoint訂制的時(shí)候經(jīng)常會(huì)遇到開發(fā)手段受限制的問(wèn)題,比如通常公司都會(huì)限制服務(wù)器的訪問(wèn)以及部署,很多開發(fā)都只能夠在客戶端來(lái)進(jìn)行2011-05-05Layui數(shù)據(jù)表格 前后端json數(shù)據(jù)接收的方法
今天小編就為大家分享一篇Layui數(shù)據(jù)表格 前后端json數(shù)據(jù)接收的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09js實(shí)現(xiàn)年月日表單三級(jí)聯(lián)動(dòng)
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)年月日表單三級(jí)聯(lián)動(dòng),生日欄表單三級(jí)聯(lián)動(dòng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03JavaScript限制在客戶區(qū)可見范圍的拖拽(解決scrollLeft和scrollTop的問(wèn)題)(2)
這篇文章主要介紹了JavaScript限制在客戶區(qū)可見范圍的拖拽,解決scrollLeft和scrollTop的問(wèn)題,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05利用javascript打開模態(tài)對(duì)話框(示例代碼)
本篇文章主要是對(duì)利用javascript打開模態(tài)對(duì)話框的示例代碼進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-01-01uniapp頁(yè)面通訊講解之uni.$emit、uni.$on、uni.$once和uni.$off
uni-app?是一個(gè)使用vue.js開發(fā)所有前端應(yīng)用的框架,下面這篇文章主要給大家介紹了關(guān)于uniapp頁(yè)面通訊之uni.$emit、uni.$on、uni.$once和uni.$off的相關(guān)資料,需要的朋友可以參考下2022-09-09點(diǎn)擊button獲取text內(nèi)容并改變樣式的js實(shí)現(xiàn)
這篇文章主要介紹了點(diǎn)擊button獲取text內(nèi)容并改變樣式的js實(shí)現(xiàn),經(jīng)測(cè)試非常實(shí)用,需要的朋友可以參考下2014-09-09