【问题标题】:How to make a navbar position:absolute; with bootstrap?如何制作导航栏位置:绝对;带引导程序?
【发布时间】:2015-06-30 21:08:29
【问题描述】:

这是我的导航栏 html:

<nav class="navbar navbar-default" role="navigation">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-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="/">EsportGRID</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse navbar-ex1-collapse">
                <ul class="nav navbar-nav">
                <li <?php if(Request::path() == "/") { echo 'class="active"'; } ?>><a href="/">Start</a></li> 
                    <li <?php if(Request::path() == "about") { echo 'class="active"'; } ?>><a href="/about">About</a></li>
                </ul>

                <ul class="nav navbar-nav navbar-right">
                    <div class="divider"></div>
                    <?php if(Auth::check()) { ?>
                    <li><a href="#">{{ ucfirst(Auth::user()->username); }}</a></li>
                    <li><a href="{{ URL::route('logout') }}">Logout</a></li>
                    <?php }else{ ?>
                    <li  <?php if(Request::path() == "login") { echo 'class="active"'; } ?>><a href="/login">Login</a></li>
                    <li <?php if(Request::path() == "registration") {echo 'class="active"'; } ?>> <a href="/registration">Registration</a></li>
                    <?php } ?>
                </ul>
            </div><!-- /.navbar-collapse -->
        </nav>

This is my CSS:

body, html {
    height: 100%;
    margin: 0;
    overflow:hidden;
}

.navbar .navbar-default{
    position:absolute !important;
}

*{
    border-radius:0 !important;
}

我一辈子都无法将导航栏位置设为绝对,让它跟随滚动。将不胜感激一些帮助。我试过使用 !important 而不是 !important,但我认为问题主要出在容器上。

【问题讨论】:

    标签: css twitter-bootstrap css-position


    【解决方案1】:

    我想你可能想要navbar-fixed-top

    http://getbootstrap.com/components/#navbar-fixed-top

    <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        ...
      </div>
    </nav>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-25
      • 2021-05-08
      • 1970-01-01
      • 2018-05-18
      相关资源
      最近更新 更多