bootstrap 在导航栏中输入 selectize.js 未展开

bootstrap input in navbar with selectize.js not expanding

我试图使导航栏中的 selectize.js 输入更大,但是应用了选择 css 并且它忽略了大输入 类。我什至尝试手动设置元素的样式宽度,但它被覆盖了。

导航栏和按钮是标准的bootstrap:

<nav class="navbar navbar-fixed-top" role="navigation">
<div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#">brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse">
        <ul class="nav navbar-nav">
            <li><a  href="#profile">Home</a></li>
            <li><a href="#browse">Browse</a></li>

            <li id="friendRequests" class="dropdown"><a id="anw" href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-smile-o fa-lg"></i>

            </a>
                <ul  class="dropdown-menu">

                </ul>
            </li>

            <li><a id ="messagesLink" href="#messages"><i class="fa fa-envelope-o fa-lg"></i>                  
        </ul>

        <ul class="nav navbar-nav navbar-right">
            <form class="navbar-form navbar-left" role="search">
                <div class="form-group">
                    <input type="text" id="searchBox" class="" placeholder="search">
                </div>
                <button type="submit" id="searchButton" class="btn btn-default color3">Go</button>
            </form>
            <img  src="" class="img-responsive navbar-brand">

            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Account <b class="caret"></b></a>
                <ul class="dropdown-menu">
                    <li><a >Settings</a></li>
                    <li class="divider"></li>
                    <li><a href="#logout">Logout</a></li>
                </ul>
            </li>
            </ul>
    </div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->

那我就开火 selectize.js :

    $(document).ready(function(){
   $('#searchBox').selectize({
            valueField: 'tagName',
            labelField: 'tagName',
            searchField: 'tagName',
            maxItems: 1,
   load: function(query, callback) {                                 }});
});

输入显示高于按钮的问题已通过按照 selectize github 中的建议注释掉溢出来解决,如下所示:

    .selectize-input {
  border: 1px solid #cccccc;
  padding: 6px 12px;
  display: inline-block;
  width: 100%;
/*  overflow: hidden;*/
  position: relative;
  z-index: 1;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-box-shadow: none;
  box-shadow: none;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
 border-radius: 4px;
}

但我不确定 属性 我应该更改什么以使输入更大。

您可以在此处查看 jsfiddle:http://jsfiddle.net/arisalexis/rncujmnk/

如果我没理解错的话,你想增加搜索框输入的宽度。

您看到的输入是由 selectize.js 创建的。因此,您无法通过向 html 中输入的内容添加 类 来控制大小。相反,您必须像这样通过 CSS 定位动态添加的输入:

.selectize-control.single .selectize-input input {
    width: 150px!important;
}

您需要使用 !important 来覆盖通过脚本添加的宽度。根据需要调整width

Working Example