html – Bootstrap 3.1.1导航栏最大化输入不再在3.2.0中最大化

前端之家收集整理的这篇文章主要介绍了html – Bootstrap 3.1.1导航栏最大化输入不再在3.2.0中最大化前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
问题:如何在Bootstrap 3.2.0导航栏中获得最大化的搜索输入?

在Bootstrap 3.1.1中,我使用以下代码作为固定的底部导航栏来显示最大化的搜索输入.

<nav class="navbar navbar-default navbar-fixed-bottom" role="seasrch">
    <div class="container">
        <form class="navbar-form">
            <div class="form-group">
                <div class="input-group input-group-sm">
                    <div class="input-group-btn">
                        <a href="#" id="new_term" class="btn btn-default" role="button"><span class="glyphicon glyphicon-leaf"></span>&nbsp;&nbsp;New</a>
                        <a href="/terms.PHP" class="btn btn-default" role="button"><span class="glyphicon glyphicon-tree-deciduous"></span>&nbsp;&nbsp;All</a>
                    </div>
                    <input type="input" class="form-control" name="search_bar_text" />
                    <div class="input-group-btn">
                        <button class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</nav>

它看起来像这样:

升级到Bootstrap 3.2.0后,我的导航栏看起来像这样:

解决方法

我从3.1.1升级到3.2.0时遇到了同样的意外体验 – 我的(顶部)导航栏形式过去占据了屏幕的全宽,现在只是一个短元素.这是我在Boostrap之后加载的自定义CSS中有用的东西(这是我在保留原始干净缩小版本的同时覆盖Bootstrap的方式):
/* Boostrap CSS 3.2.0 had these new lines in the navbar-form that
   were different from 3.1.1 [it's all in @media (min-width: 768px)
   so this behavior only shows up on higher resolutions] */
.navbar-form .input-group {
    display: inline-table;
    vertical-align: middle;
}
.navbar-form .input-group .input-group-addon,.navbar-form .input-group .input-group-btn,.navbar-form .input-group .form-control {
    width: auto;  /* HERE IS THE CULPRIT */
}
/** SOLUTION: in custom CSS **/
/* make sure navbar-form's input-group goes 100% i.e. full width of screen 
   to compliment the display: inline-table; that showed up in 3.2.0 */
.navbar-form .input-group {
      width: 100%;
}
/* override width: auto; that showed up in 3.2.0
   with at least 1px for the addon or btn (I had an addon) */
.navbar-form .input-group .input-group-addon,.navbar-form .input-group .input-group-btn {
      width: 1px;
}
/* separate .form-control and give it width: 100%; */
.navbar-form .input-group .form-control {
        width: 100%;
}

猜你在找的HTML相关文章