Chosen.js styling not conforming to Bootstrap3 styles

后端 未结 5 1020
既然无缘
既然无缘 2021-01-30 11:08

Im using chosen.js v1.0 and am using it in my project with Bootstrap 3 but the styles of my select boxes are not conforming to bootstrap 3 styles at all.

Am I doing any

相关标签:
5条回答
  • 2021-01-30 11:49

    An alternate stylesheet for Chosen 1.0. This one is supposed to integrate better with Bootstrap 3.0.

    Available here http://alxlit.github.io/bootstrap-chosen/

    screenshot of chosen alternative

    0 讨论(0)
  • 2021-01-30 11:59

    Actually, there is someone who created a Bootstrap 3.0 CSS theme for Chosen.

    Some screens:

    enter image description here

    enter image description here

    enter image description here

    The theme is available in this Github issue Use Gist below.


    Edit

    I've created a Fiddle using the same HTML as the official Chosen documentation page with the Bootstrap theme applied. (added form-control to all selects and removed style="width:350px;")

    And also, I'll be maintaining the theme in this gist: https://gist.github.com/koenpunt/6424137

    0 讨论(0)
  • 2021-01-30 12:02

    There is also another alternate theme supports Bootstrap 3 here https://github.com/dbtek/chosen-bootstrap.

    Looks like native bs inputs.

    chosen-bootstrap

    0 讨论(0)
  • 2021-01-30 12:11

    Chosen.js (chosen.css) and the bootstrap css both add CSS styles to your inputs (selects). Try to load chose.css after bootstrap.css:

      <link rel="stylesheet" href="bootstrap3/bootstrap-3.0.0-wip/dist/css/bootstrap.css">
      <link rel="stylesheet" href="docsupport/style.css">
      <link rel="stylesheet" href="docsupport/prism.css">
      <link rel="stylesheet" href="chosen.css">
      <style type="text/css" media="all">
        /* fix rtl for demo */
        .chosen-rtl .chosen-drop { left: -9000px; }
      </style>
    

    After doing this see: Right border of the AddThis counter missing with Twitter's Bootstrap 3. It seems the CSS's universal selector to set box-sizing to border-box caused most of the trouble.

    To fix this reset the box-sizing of the elements you apply chosen() on:

    In the case of $('#select-input').chosen(); you will also set:

    #select-input
    {
      -webkit-box-sizing: content-box;
         -moz-box-sizing: content-box;
          box-sizing: content-box;
    }
    

    NB by default chosen.js bundles an old version of jQuery. Twitter Bootstrap (javascript) requires the newest version (<2) of jQuery

    0 讨论(0)
  • 2021-01-30 12:12

    If you want to change the select box sizes to be responsive you can use:

    [class*="col-"] .chosen-container {
        width:98%!important;
    }
    [class*="col-"] .chosen-container .chosen-search input[type="text"] {
        padding:2px 4%!important;
        width:90%!important;
        margin:5px 2%;
    }
    [class*="col-"] .chosen-container .chosen-drop {
        width: 100%!important;
    }
    

    Source : https://github.com/harvesthq/chosen/issues/1004

    0 讨论(0)
提交回复
热议问题