Bootstrap CSS組件之輸入框組
本文實例為大家分享了Bootstrap輸入框組的具體代碼,供大家參考,具體內(nèi)容如下
了解table-cell的表格width設(shè)置為1%的原因。
http://www.tuicool.com/articles/VzUVfyi
通過向輸入域添加前綴和后綴的內(nèi)容,您可以向用戶輸入添加公共的元素。例如,您可以添加美元符號,或者在 Twitter 用戶名前添加 @,或者應(yīng)用程序接口所需要的其他公共的元素。
input-group(input-group-xs,input-group-sm,input-group-lg)、input-group-addon、form-control
//源碼 //各元素設(shè)置為等高顯示,input-group輸入框組display:table,input-group-addon和form-control設(shè)置display:table-cell .input-group { position: relative; display: table; border-collapse: separate; } //input-group如果同時應(yīng)用了col樣式,則取消浮動和左右padding .input-group[class*="col-"] { float: none; padding-right: 0; padding-left: 0; } .input-group .form-control { position: relative; z-index: 2; float: left; width: 100%; margin-bottom: 0; } .input-group-addon, .input-group-btn { //設(shè)置最小值,以便表格模式進(jìn)行近似等分 width: 1%; white-space: nowrap; vertical-align: middle; } .input-group-addon, .input-group-btn, .input-group .form-control { display: table-cell; }
1.基本用法
有時需要將文本輸入框(input-group)和文字或者小icon組合在一起進(jìn)行顯示
2.復(fù)選框與單選框作為addon .input-group-addon(可以放置label,icon,checkbox,radio)
3.按鈕作為addon
4.下拉菜單按鈕作為addon
5.分段按鈕作為addon
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Bootstrap從3.0版本開始全面支持移動平臺,貫徹移動先行宗旨 --> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Bootstrap 101 Template</title> <!-- Bootstrap --> <link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <!-- 將文本輸入框(input-group)和文字或者小icon組合在一起進(jìn)行顯示: input-group/input-group-addon/form-control--> <div class="input-group"> <span class="input-group-addon">$</span> <input type="text" class="form-control"> </div> <div class="input-group"> <input type="text" class="form-control"> <span class="input-group-addon">0.0</span> </div> <!-- 復(fù)選框與單選框作為addon .input-group-addon(可以放置label,icon,checkbox,radio) 源碼中如果對margin-top值進(jìn)行了消除,方便對齊 input-group/input-group-addon/form-control--> <div class="input-group"> <span class="input-group-addon"><input type="checkbox"></span> <input type="text" class="form-control"> </div> <div class="input-group"> <span class="input-group-addon"><input type="radio"></span> <input type="text" class="form-control"> </div> <!-- 按鈕作為addon input-group/input-group-addon/form-control--> <div class="input-group"> <span class="input-group-addon"> <button class="btn btn-default">Go!</button> </span> <input type="text" class="form-control"> </div> <div class="input-group"> <input type="text" class="form-control"> <span class="input-group-addon"> <button class="btn btn-default">Go!</button> </span> </div> <!-- 下拉菜單按鈕作為addon: input-group/input-group-btn/dropdown-menu/form-control--> <div class="input-group"> <input type="text" class="form-control"> <div class="input-group-btn"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> 前端 <span class="caret"></span> </button> <ul class="dropdown-menu"> <li><a href="#">HTML</a></li> <li><a href="#">JS</a></li> <li><a href="#">CSS</a></li> </ul> </div> </div> <!-- 分段按鈕作為addon: 在input-group-btn里有多個btn--> <div class="input-group"> <input type="text" class="form-control"> <div class="input-group-btn"> <button class="btn btn-default" type="button">按鈕A</button> <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"> <span class="caret"></span> </button> <button class="btn btn-default" type="button">按鈕B</button> <button class="btn btn-default" type="button">按鈕C</button> <ul class="dropdown-menu"> <li>1</li> <li>2</li> <li>3</li> </ul> </div> </div> <!-- bootstrap是基于jQuery--> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script> </body> </html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 學(xué)習(xí)使用Bootstrap輸入框、導(dǎo)航、分頁等常用組件
- Bootstrap輸入框組件簡單實現(xiàn)代碼
- bootstrap輸入框組件使用方法詳解
- Bootstrap基本組件學(xué)習(xí)筆記之input輸入框組(9)
- Bootstrap3 input輸入框插入glyphicon圖標(biāo)的方法
- bootstrap下拉列表與輸入框組結(jié)合的樣式調(diào)整
- bootstrap布局中input輸入框右側(cè)圖標(biāo)點擊功能
- 基于Bootstrap使用jQuery實現(xiàn)輸入框組input-group的添加與刪除
- BootStrap點擊下拉菜單項后顯示一個新的輸入框?qū)崿F(xiàn)代碼
- Bootstrap輸入框組件使用詳解
相關(guān)文章
ECMAScript?的?6?種簡單數(shù)據(jù)類型
這篇文章主要介紹了ECMAScript的?6?種簡單數(shù)據(jù)類型,ECMAScript的數(shù)據(jù)類型很靈活,一種數(shù)據(jù)類型可以當(dāng)作多種數(shù)據(jù)類型來使用,具體使用詳情文章詳細(xì)介紹需要的小伙伴可以參考一下2022-06-06JS表格組件BootstrapTable行內(nèi)編輯解決方案x-editable
這篇文章主要介紹了JS組件系列BootstrapTable行內(nèi)編輯解決方案:x-editable,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-09-09