简体   繁体   English

使用Twitter Bootstrap 3修复了导航栏

[英]Fixed Navigation Bar using Twitter Bootstrap 3

I'm using Twitter Bootstrap 3 for my website. 我正在为我的网站使用Twitter Bootstrap 3 I'd like to have a fixed navigation bar which needs to be on after some certain point where the user scrolls down. 我想要一个固定的导航栏,该导航栏需要在用户向下滚动的某个特定点之后打开。

I've used Affix() and i can get the navigation bar to appeared at some certain point. 我已经使用过Affix()并且可以使导航栏出现在某个特定点。

But the challenge is when the user scrolls down, the navigation bar appears on the top and the width of the navigation bar is not 100%. 但是挑战在于,当用户向下滚动时,导航栏出现在顶部,并且导航栏的宽度不是100%。

I wanted the width of the navigation bar to be 100% even after scrolling the page. 即使滚动页面后,我也希望导航栏的宽度为100%。

Here's the FIDDLE . 这是FIDDLE

Please scroll down in the result segment and notice navigation bar. 请在结果部分中向下滚动并注意导航栏。

It disappears and then appears at some scroll point. 它消失,然后出现在某个滚动点。 But the width of the navigation bar is not the same when it was at the beginning. 但是导航栏的宽度与开始时的宽度不同。

Please help me in fixing it. 请帮助我修复它。

Just use width: 100%; 只需使用width: 100%; on .navigation 在。 .navigation

.navigation {
    background: #fff;
    position: relative;
    width: 100%;
}

Demo 演示版

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

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