CSS Bootstrap 3 多个导航栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20637235/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 01:20:42  来源:igfitidea点击:

Bootstrap 3 multiple navbars

csstwitter-bootstrap

提问by woj_jas

I'm having trouble with multiple bootstrap in Twitter Bootstrap 3. First Navbar is working ok with resizing and responsive. Second navbar doesn't work properly in normal resolution, but when i try to do size to responsive and after resize it's working okay.

我在 Twitter Bootstrap 3 中遇到了多个引导程序的问题。第一个导航栏在调整大小和响应方面工作正常。第二个导航栏在正常分辨率下无法正常工作,但是当我尝试调整大小以响应并调整大小后,它可以正常工作。

Here's some code:

这是一些代码:

<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->  <!--<![endif]-->

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width">

    <link rel="stylesheet" href="css/bootstrap.css">
    <style>
    </style>
    <link rel="stylesheet" href="css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="css/main.css">
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">

    <script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
    <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.1.min.js"><\/script>')</script>

    <script src="js/vendor/bootstrap.js"></script>

    <script src="js/main.js"></script>

    <script>
        var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
        (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
            g.src='//www.google-analytics.com/ga.js';
            s.parentNode.insertBefore(g,s)}(document,'script'));


    </script>


<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<div id="wrap">
<div class="navbar navbar-inverse navbar-static-top hr" style="background:black;">
    <div class="container">

        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <div class="navbar-brand logo"></div>
        </div>
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav" style="font-size:17px;">
                <li><a href="#">Item1</a></li>
                <li class="divider-vertical"></li>
                <li><a href="#about">Item2</a></li>
                <li class="divider-vertical"></li>
                <li><a href="#contact">Item3</a></li>
                <li class="divider-vertical"></li>
                <li><a href="#contact">Item4</a></li>
                <li class="divider-vertical"></li>
                <li><a href="#contact">Item</a></li>
                <li class="divider-vertical"></li>
                <li><a href="#contact">Item6</a></li>
                <li class="divider-vertical"></li>
                <li><a href="#contact">Item7</a></li>

            </ul>

        </div>
    </div>
</div>
    <div class="navbar navbar-inverse navbar-static-top hr" style="background:#ececec; border-top:none; ">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse2">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>
            <div class="navbar-collapse2 collapse">
                <ul class="nav navbar-nav" style="font-size:17px;">
                    <li><a href="#">it1d</a></li>
                    <li class="divider-vertical"></li>
                    <li><a href="#about">it2d</a></li>
                    <li class="divider-vertical"></li>
                    <li><a href="#contact">it3d</a></li>
                    <li class="divider-vertical"></li>
                    <li><a href="#contact">it4d</a></li>
                    <li class="divider-vertical"></li>
                    <li><a href="#contact">it5d</a></li>
                    <li class="divider-vertical"></li>
                    <li><a href="#contact">it6d</a></li>
                    <li class="divider-vertical"></li>
                    <li><a href="#contact">it7d</a></li>

                </ul>
            </div>
        </div>
    </div>


<!-- FOOTER -->

And Bootply: http://bootply.com/101032

和 Bootply:http://bootply.com/101032

Best Regards and thanks for help.

最好的问候并感谢您的帮助。

Edit: Ok I have resolution.

编辑:好的,我有决心。

If you have same problem you have to change data target for second navbar and in starting div add ( i changed for .main-nav) and after add your data-target class on the end of navbar item.

如果您有同样的问题,您必须更改第二个导航栏的数据目标,并在开始 div 添加(我更改为 .main-nav)并在导航栏项目的末尾添加您的数据目标类之后。

<div class="collapse navbar-collapse main-nav">

Here's link to bootply how to do it proper

这是引导如何正确执行的链接

http://bootply.com/101069

http://bootply.com/101069

回答by mcmac

try changing <div class="navbar-collapse2 collapse">to that <div class="navbar-collapse collapse">

尝试更改 <div class="navbar-collapse2 collapse"><div class="navbar-collapse collapse">

回答by regdoug

If you add the following bit of CSS (either in a styletag or a custom css file), it should fix your problem.

如果您添加以下 CSS(在style标签或自定义 css 文件中),它应该可以解决您的问题。

@media only screen and (min-width: 768px) {
  .navbar-collapse2.collapse {
    display: block !important;
    height: auto !important;
    padding-bottom: 0px;
    overflow: visible !important;
  }
}

I pulled this code from the code in bootstrap.css for .navbar-collapse

我从 bootstrap.css 中的代码中提取了这段代码 .navbar-collapse