问答详情
源自:6-7 响应式导航条

bootstrap的响应式导航条

https://img.mukewang.com/5b3201ee0001d2ae03580399.jpg

当导航栏内存在表单的时候,使用响应式导航条会出现两个这样的滚动条,怎么避免这种情况的产生呢?


<div class="navbar navbar-inverse">

    <!--navbar-inverse和navabar-default,前者是黑色,后者是灰色-->

    <div class="navbar-header">

        <button class="navbar-toggle" data-target="#hamb2" data-toggle="collapse">

            <span class="icon-bar"></span>

            <span class="icon-bar"></span>

            <span class="icon-bar"></span>

        </button>

        <div class="navbar-brand">

            <span class="highlight">7thHeaven</span>

            </div>

    </div>

    <div id="hamb2" class="collapse navbar-collapse navbar-responsive-collapse">

       <ul class="nav navbar-nav">

           <li class="active"><a href="#">Home</a></li>

               <li><a href="#">首页</a></li>

                <li class="btn-group">

                <a href="" class="dropdown-toggle" data-toggle="dropdown">课程列表<span class="caret"></span></a>

            <ul class="dropdown-menu">

                <li class="dropdown-header">前端</li>

                <li><a href="#">HTML5</a></li>

                <li><a href="#">CSS3</a></li>

                <li><a href="#">Vue.js</a></li>

                <li><a href="#">JQuery</a></li>

                <li class="nav-divider"></li>

                <li class="dropdown-header">Java</li>

                <li><a href="#">Java</a></li>

                <li><a href="#">Java</a></li>

                <li><a href="#">Java</a></li>

                <li><a href="#">Java</a></li>

                <li class="nav-divider"></li>

                <li class="dropdown-header">Python</li>

                <li><a href="#">Python</a></li>

                <li><a href="#">Python</a></li>

                <li><a href="#">Python</a></li>

                <li><a href="#">Python</a></li>

            </ul>

        </li>

        <li><a href="#">联系我们</a></li>

        <li><a href="#">关于我们</a></li>

        <li><a href="#">注册</a></li>

        <li><a href="#">登陆</a></li>

        <form role="from" class="navbar-form navbar-right">

            <div class="form-group">

                <input type="text" class="form-control" placeholder="请输入..." />

            </div>

            <button class="btn btn-default">

                搜索

                <span class="glyphicon glyphicon-search"></span>

            </button>

        </form>

    </ul>

    </div>

</div>


提问者:ZagO 2018-06-26 17:06

个回答

  • Dong_Cool
    2018-06-28 15:44:13

    <div class="navbar navbar-default" role="navigation">

      <div class="navbar-header">

          <!-- .navbar-toggle样式用于toggle收缩的内容,即nav-collapse collapse样式所在元素 -->

           <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-responsive-collapse">

             <span class="sr-only">Toggle Navigation</span>

             <span class="icon-bar"></span>

             <span class="icon-bar"></span>

             <span class="icon-bar"></span>

           </button>

           <!-- 确保无论是宽屏还是窄屏,navbar-brand都显示 -->

           <a href="##" class="navbar-brand">慕课网</a>

      </div>

      <!-- 屏幕宽度小于768px时,div.navbar-responsive-collapse容器里的内容都会隐藏,显示icon-bar图标,当点击icon-bar图标时,再展开。屏幕大于768px时,默认显示。 -->

      <div class="collapse navbar-collapse navbar-responsive-collapse">

        <ul class="nav navbar-nav">

          <li class="active"><a href="##">网站首页</a></li>

          <li><a href="##">系列教程</a></li>

          <li><a href="##">名师介绍</a></li>

          <li><a href="##">成功案例</a></li>

          <li><a href="##">关于我们</a></li>

    </ul>

    <form action="##" class="navbar-form navbar-left" rol="search">

            <div class="form-group">

           <input type="text" class="form-control" placeholder="请输入关键词" />

            </div>

            <button type="submit" class="btn btn-default">搜索</button>

        </form>

      </div>

    </div>

    我没有出现这个问题啊