Bootstrap Select 选择器问题

Bootstrap Select Picker Issues

我正在尝试让我的 Multi-Select 看起来像我在此处找到的示例之一:https://silviomoreto.github.io/bootstrap-select/examples/. I have downloaded the SelectPicker.js from here: http://silviomoreto.github.io/bootstrap-select/。它并排显示了 2 个盒子,我无法让看起来普通的盒子消失。

<html>
    <head>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    </head>
    <body class="container">
        <br/><br/><br/><br/><br/>
        <div class="container-fluid">
            <div class="form-group">
              <select class="selectpicker" id="rating" multiple data-selected-text-format="count > 3">
                <option>G</option>
                <option>PG</option>
                <option>PG-13</option>
                <option>R</option>
                <option>NC-17</option>
              </select>
            </div>
        </div>
        <hr/>
        <button onclick=doThis();>SUBMIT</button>    
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script src="../Documents/Movies_New/movies_ui/bootstrap/js/bootstrap-select.js"></script>
        <script type="text/javascript">
        $(document).ready(function() {
            $('.selectpicker').selectpicker();

            function doThis(){
                alert('Submit');
            }
        });
        </script>
    </body>
</html>

我想你错过了 'bootsrap-select' 的 css。

试试这个。

<html>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <!-- Latest compiled and minified CSS -->
            <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">

</head>
<body class="container">
    <br/><br/><br/><br/><br/>
    <div class="container-fluid">
        <div class="form-group">
          <select class="selectpicker" id="rating" multiple data-selected-text-format="count > 3">
            <option>G</option>
            <option>PG</option>
            <option>PG-13</option>
            <option>R</option>
            <option>NC-17</option>
          </select>
        </div>
    </div>
    <hr/>
    <button onclick=doThis();>SUBMIT</button>    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!-- Latest compiled and minified JavaScript -->
            <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
        $('.selectpicker').selectpicker();

        function doThis(){
            alert('Submit');
        }
    });
    </script>
</body>

我认为您缺少 link bootstrap-select.css。我在你的例子中使用了它..

<html>
    <head>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">

<!-- Latest compiled and minified JavaScript -->
    </head>
    <body class="container">
        <br/><br/><br/><br/><br/>
        <div class="container-fluid">
            <div class="form-group">
              <select class="selectpicker" id="rating" multiple data-selected-text-format="count > 3">
                <option>G</option>
                <option>PG</option>
                <option>PG-13</option>
                <option>R</option>
                <option>NC-17</option>
              </select>
            </div>
        </div>
        <hr/>
        <button onclick=doThis();>SUBMIT</button>    
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>

        <script type="text/javascript">
        $(document).ready(function() {
            $('.selectpicker').selectpicker();

            function doThis(){
                alert('Submit');
            }
        });
        </script>
    </body>
</html>