最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Bootstrap selectpicker does not work with bootstrap "has-error" class - Stack Overflow

programmeradmin1浏览0评论

Im having trouble with bootstrap selectpicker and bootstraps "has-error" class. If an select tag has "has-error" class without selectpicker then a red border is niceley displayed around it. When i add the selectpicker then it is not. What can i do so that "has-error" will display a red border around select tag with bootstrap selectpicker?

jsfiddle: /

code:

<div class="form-group has-error">
    <select class="form-control">
        <option>Option 1</option>
        <option>Option 2</option>
        <option>Option 3</option>
    </select>
</div>

// include next line to see that red border dissapears
// $('select').selectpicker();

Im having trouble with bootstrap selectpicker and bootstraps "has-error" class. If an select tag has "has-error" class without selectpicker then a red border is niceley displayed around it. When i add the selectpicker then it is not. What can i do so that "has-error" will display a red border around select tag with bootstrap selectpicker?

jsfiddle: http://jsfiddle/mfrup5bL/149/

code:

<div class="form-group has-error">
    <select class="form-control">
        <option>Option 1</option>
        <option>Option 2</option>
        <option>Option 3</option>
    </select>
</div>

// include next line to see that red border dissapears
// $('select').selectpicker();
Share Improve this question asked Nov 7, 2017 at 20:06 user1985273user1985273 1,96719 gold badges52 silver badges92 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

You can add this style:

.has-error .form-control > .selectpicker {
    border-color: #a94442;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
}

See a demo here.

You could add the color to the element that is created by the selectpicker...

button.btn.dropdown-toggle.selectpicker.btn-default {
    border-color: rgb(169, 68, 66);
}

To avoid CSS overriding, you could update bootstrap-select to the latest version which provides the required styling.

发布评论

评论列表(0)

  1. 暂无评论