亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

章節
問答
課簽
筆記
評論
占位
占位

表單控件狀態(禁用狀態)

Bootstrap框架的表單控件的禁用狀態和普通的表單禁用狀態實現方法是一樣的,在相應的表單控件上添加屬性“disabled”。和其他表單的禁用狀態不同的是,Bootstrap框架做了一些樣式風格的處理:
/*源碼請查看bootstrap.css文件第1723行~第1729行*/

.form-control[disabled],
.form-control[readonly],
fieldset[disabled] .form-control {
cursor: not-allowed;
background-color: #eee;
opacity: 1;
}

使用方法為:只需要在需要禁用的表單控件上加上“disabled”即可:

<input class="form-control" type="text" placeholder="表單已禁用,不能輸入" disabled>

運行效果如下或查看右側結果窗口:

在使用了“form-control”的表單控件中,樣式設置了禁用表單背景色為灰色,而且手型變成了不準輸入的形狀。如果控件中不使用類名“form-control”,禁用的控件只會有一個不準輸入的手型出來。
/*源碼請查閱bootstrap.css文件第1781行~第1794行*/

input[type="radio"][disabled],
input[type="checkbox"][disabled],
.radio[disabled],
.radio-inline[disabled],
.checkbox[disabled],
.checkbox-inline[disabled],
fieldset[disabled] input[type="radio"],
fieldset[disabled] input[type="checkbox"],
fieldset[disabled] .radio,
fieldset[disabled] .radio-inline,
fieldset[disabled] .checkbox,
fieldset[disabled] .checkbox-inline {
cursor: not-allowed;
}

在Bootstrap框架中,如果fieldset設置了disabled屬性,整個域都將處于被禁用狀態。

<form role="form">
<fieldset disabled>
  <div class="form-group">
  <label for="disabledTextInput">禁用的輸入框</label>
    <input type="text" id="disabledTextInput" class="form-control" placeholder="禁止輸入">
  </div>
  <div class="form-group">
  <label for="disabledSelect">禁用的下拉框</label>
    <select id="disabledSelect" class="form-control">
  <option>不可選擇</option>
  </select>
  </div>
  <div class="checkbox">
  <label>
    <input type="checkbox">無法選擇
  </label>
  </div>
  <button type="submit" class="btnbtn-primary">提交</button>
</fieldset>
</form>

運行效果如下或查看右側結果窗口:

據說對于整個禁用的域中,如果legend中有輸入框的話,這個輸入框是無法被禁用的。我們一起來驗證一下:

<form role="form">
<fieldset disabled>
<legend><input type="text" class="form-control" placeholder="顯然我顏色變灰了,但是我沒被禁用,不信?單擊試一下" /></legend>
    …
</fieldset>
</form>

運行效果如下或查看右側結果窗口:

 

 

 

 

任務

本小節沒有代碼任務,單擊“提交”按鈕進行下一個小節學習。

?不會了怎么辦
||

提問題

寫筆記

公開筆記
提交
||

請驗證,完成請求

由于請求次數過多,請先驗證,完成再次請求

加群二維碼

打開微信掃碼自動綁定

您還未綁定服務號

綁定后可得到

  • · 粉絲專屬優惠福利
  • · 大咖直播交流干貨
  • · 課程更新,問題答復提醒
  • · 賬號支付安全提醒

收藏課程后,能更快找到我哦~

使用 Ctrl+D 可將課程添加到書簽

邀請您關注公眾號
關注后,及時獲悉本課程動態

舉報

0/150
提交
取消
全部 精華 我要發布
全部 我要發布
最熱 最新
只看我的

手記推薦

更多

本次提問將花費2個積分

你的積分不足,無法發表

為什么扣積分?

本次提問將花費2個積分

繼續發表請點擊 "確定"

為什么扣積分?