Bootstrap移动导航栏无法正确显示

时间:2016-12-22 01:17:07

标签: jquery html css twitter-bootstrap jquery-mobile

Navbar在桌面上正常运行,但在手机上它看起来像这样:

如何在移动版上禁用菜单或修复它的最佳方法是什么?

Navbar代码:

  <nav class="navbar navbar-vira navbar-fixed-top">
           <div class="navigation-bar">
           <div class="container">
                <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                            <span class="sr-only">Zamknij nawigację</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <div class="logo">
                            <a href="#">XXXX</a>
                        </div>
                </div>
                <ul class="nav navbar-nav navbar-right font-white">
                    <li class="active"><a href="#">Home</a></li>
                    <li><a href="#about">O mnie</a></li>
                    <li><a href="#ofert">Oferta</a></li>
                    <li><a href="#contact">Kontakt</a></li>
                </ul>
            </div>
            </div>
        </nav>

2 个答案:

答案 0 :(得分:0)

如果您希望菜单不显示在手机上。您可以考虑使用媒体查询并限制其显示

检查以下代码段

&#13;
&#13;
@media screen and (min-width:200px) and (max-width:500px){
  ul.nav{
    display:none;
  }
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-vira navbar-fixed-top">
           <div class="navigation-bar">
           <div class="container">
                <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                            <span class="sr-only">Zamknij nawigację</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <div class="logo">
                            <a href="#">XXXX</a>
                        </div>
                </div>
                <ul class="nav navbar-nav navbar-right font-white">
                    <li class="active"><a href="#">Home</a></li>
                    <li><a href="#about">O mnie</a></li>
                    <li><a href="#ofert">Oferta</a></li>
                    <li><a href="#contact">Kontakt</a></li>
                </ul>
            </div>
            </div>
        </nav>
&#13;
&#13;
&#13;

希望它有所帮助 PS:查看全屏输出

答案 1 :(得分:0)

要添加另一个显示如何完全隐藏导航的答案,
以下HTML应该允许导航正常工作。您显然需要为下拉功能添加Bootstrap jQuery。我认为徽标div引起了问题。

<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-nav-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="#">XXXX</a>
            </div>
            <div class="collapse navbar-collapse" id="main-nav-collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li class="active"><a href="#">Home</a></li>
                    <li><a href="#about">O mnie</a></li>
                    <li><a href="#ofert">Oferta</a></li>
                    <li><a href="#contact">Kontakt</a></li>
                </ul>
            </div>
        </div>
    </nav>