简体   繁体   English

固定的Bootstrap导航栏

[英]Fixed Bootstrap navigation bar

Aloha! 阿罗哈! I am trying to have Bootstrap's navigation stay at the top of the page and not follow me around as I am scrolling. 我正在尝试使Bootstrap的导航停留在页面顶部,并且在滚动时不跟随我。

My code looks like this: 我的代码如下所示:

<nav class="navbar  navbar-default navbar-fixed-top" role="navigation">
    <div class="container">

CSS: CSS:

body {padding-top: 70px;}
.navigation {padding-bottom: 30px:}
.navbar-fixed-top .nav { padding: 15px 0;}
.navbar-fixed-top .navbar-brand { padding: 0 15px;}
.navbar-nav > li{
  padding-left:30px;
  padding-right:30px;
}
.navcontainer {
padding-bottom: 30px;
}

I've been looking into it but the only answer I found was to add bottom padding to the nav bar which has been unsuccessful. 我一直在研究它,但我发现的唯一答案是在导航栏上添加了底部填充,但没有成功。 Would really appreciate some help. 非常感谢您的帮助。 Thank you :) 谢谢 :)

Remove navbar-fixed-top and remove body padding top. 拆下固定在顶部的导航栏,并拆下车身衬垫的顶部。 Bootstrap navbar-fixed-top archors it to the top of the browser even when scrolling. 即使在滚动时,也可以将导航栏固定在顶部的弓箭引导到浏览器的顶部。

.navbar-fixed-top {
    position: fixed;
    right: 0;
    left: 0;
    z-index: 1030;
    top: 0;
    border-width: 0 0 1px;
}

http://jsfiddle.net/63zvdLyu/8/ http://jsfiddle.net/63zvdLyu/8/

I have found a resource that just might suit your need here . 我发现,也许会满足您的需要的资源在这里 You can open up that example website with the inspect element feature in Google Chrome and then just copy the code to your favorite text editor and then you can go through the code there. 您可以使用Google Chrome浏览器中的inspect element功能打开该示例网站,然后将代码复制到您喜欢的文本编辑器中,然后可以在其中浏览代码。 If you need more help place it in the comments. 如果您需要更多帮助,请将其放在注释中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM