Bootstrap - 导航栏不适用于所有屏幕

时间:2017-05-09 08:35:27

标签: html css twitter-bootstrap

我是新人,我不会说英语很好,但我认为你可以理解我并帮助:)。我刚开始使用bootstrap进行冒险。 所以...我的导航栏只有4 / li /适用于所有屏幕尺寸。 这是代码:

<!-- Navigation -->
<nav class="navbar navbar-default" role="navigation">
    <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <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 is hidden on larger screens, but visible when the menu is collapsed -->
            <a class="navbar-brand" href="index.html">Business Casual</a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li>
                    <a href="index.html">Home</a>
                </li>
                <li>
                    <a href="about.html">About</a>
                </li>
                <li>
                    <a href="blog.html">Blog</a>
                </li>
                <li>
                    <a href="contact.html">Contact</a>
                </li>
            </ul>
        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container -->
</nav>

但问题是当我修改导航栏并添加例如2个/ li /像这样:

<!-- Navigation -->
<nav class="navbar navbar-default " role="navigation">
<div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
            <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="#">Health</a>
    </div>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav ">
            <li>
                <a href="#">Main menu</a>
            </li>
            <li>
                <a href="#>Doctors</a>
            </li>
            <li>
                <a href="#">Presciprions</a>
            </li>
            @if(Auth::check())
                <li>
                    <a href="#">Panel</a>
                </li>
                <li>
                    <a href="#">Logout</a>
                </li>
            @else
                <li>
                    <a href="#">Login</a>
                </li>
                <li>
                    <a href="#">Register</a>
                </li>
            @endif
        </ul>
    </div>
    <!-- /.navbar-collapse -->
</div>
<!-- /.container -->

我的导航栏在768和992 /和/ 992和1200之间没有响应屏幕。我认为,因为它在平板电脑上无法工作而且我的导航栏正在卷曲 - 我想总是在一条线上,无论女巫大小屏幕是。我的错误在哪里?

Link to page

1 个答案:

答案 0 :(得分:1)

请将此代码添加到自定义文件css

@media screen (min-width: 768px) and (max-width:1200){
   .nav>li>a {
    padding: 36px 5px;
  }
}