Twitter bootstrap 3 Bootstrap 3-容器中的固定响应导航栏(侧面无背景色)
怎么做 固定导航栏在中心,但没有背景色在两侧 导航栏的宽度应与容器的宽度相同,然后是导航栏的背景色,指向您不应看到的容器(包含它)的侧面 有什么想法吗 此外,导航栏必须随着容器宽度的调整而缩小,然后是页面宽度的调整:所以响应导航栏 怎么做Twitter bootstrap 3 Bootstrap 3-容器中的固定响应导航栏(侧面无背景色),twitter-bootstrap-3,Twitter Bootstrap 3,怎么做 固定导航栏在中心,但没有背景色在两侧 导航栏的宽度应与容器的宽度相同,然后是导航栏的背景色,指向您不应看到的容器(包含它)的侧面 有什么想法吗 此外,导航栏必须随着容器宽度的调整而缩小,然后是页面宽度的调整:所以响应导航栏 怎么做 提前感谢。从以下位置修复默认导航栏: 将导航栏包装在自己的.container div中,并将此div包装在您修复的其他div中: #fixme {position: fixed;left: 0;right: 0; top:0;} /* prevent ove
提前感谢。从以下位置修复默认导航栏: 将导航栏包装在自己的.container div中,并将此div包装在您修复的其他div中:
#fixme {position: fixed;left: 0;right: 0; top:0;}
/* prevent overlap */
body{padding-top:70px;}
html
<div id="fixme">
<div class="container">
<!-- your navbar here -->
</div>
</div>
在此之后,导航栏本身没有背景色。要解决此问题,请将导航栏包装在一个额外的div(在.containter div内)中并在其上应用背景色:
.navbar > .container > div
{
background-color: pink;
}
当您在没有额外div的.container上应用此背景时,由于网格的槽(填充),您的背景将比两侧的内容宽15px
例如:
html:
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div>
<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>
<a class="navbar-brand" href="#">Project name</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="../navbar/">Default</a></li>
<li><a href="../navbar-static-top/">Static top</a></li>
<li class="active"><a href="./">Fixed top</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
-
- 导航标题
我使用的是最新版本的Bootsrap,我必须像这样覆盖“navbar default”类:
.navbar-default{
background-image: none;
-webkit-box-shadow: none;
border-style : none;
background-color: white; // the color i chose
}
结果是我的导航栏没有更多的边框/背景样式,我终于可以在我的div中应用我的样式了!(phewww)我也在为同样的问题而挣扎。我通过添加一些jquery解决了这个问题,使“.navbar”与“.container”的宽度相同
用这个来演示plzThanks代码。天才。你是个天才。
.navbar-default{
background-image: none;
-webkit-box-shadow: none;
border-style : none;
background-color: white; // the color i chose
}
$(document).ready(function () {
var siteWidth = $('.container').width();
$('.navbar').width(siteWidth);
});