2017-02-01 84 views
0

我有一個select2選擇菜單。Bootstrap select2錯誤樣式

剝離版本,例如:

<div class="form-group has-error"> 
     <select name="description_id" class="select2"> 

// <options> 

</div> 

運用has-error到文本輸入將顯示圍繞輸入一個紅色邊框。這對於s​​elect2菜單不起作用。我錯過了什麼?

我使用bootstrap3和最新選擇2:

https://select2.github.io/

我讀過這個頁面,並試圖解決方案,但它不工作:

https://xcellerant.net/2013/12/05/adding-bootstrap-error-styling-to-a-select2/

回答

5

的解決方案在您發佈的頁面上,適用於舊版本select2。最新的版本,使用這個CSS代碼在這裏:

.has-error .select2-selection { 
    border-color: rgb(185, 74, 72) !important; 
} 

現在有了這個代碼,並使用has-error類,你可以得到適當的偏紅錯誤顏色:

​​

Select2 with has-error class

的jsfiddle例如:https://jsfiddle.net/k9phxgnd/1/

+0

就是這樣,非常感謝,可以在12小時內獎勵賞金:-) – Hardist