Bootstrap新手3.客户希望导航栏颜色跨越浏览器窗口宽度,同时保持实际导航栏居中。旧CSS意味着添加背景图像重复,但我使用旋转木马背景设置“覆盖”z-index -99。它似乎应该是简单的和堆叠问题。我已经尝试将它放在body标签内联,正文css样式上,我已经尝试重新创建导航栏,但它左对齐,我找不到解决方案。任何帮助,将不胜感激。 enter image description here
body {
background-color: #0d4ea2;
}
.carousel { z-index: -99; } /* keeps this behind all content */
.carousel .item {
position: fixed;
width: 100%;
height: 100%;
-webkit-transition: opacity 1s;
-moz-transition: opacity 1s;
-ms-transition: opacity 1s;
-o-transition: opacity 1s;
transition: opacity 1s;
}
.carousel .one {
background-image: url(../images/auto-wheel.jpg);
background-size: cover;
-moz-background-size: cover;
}
.carousel .two {
background-image: url(../images/auto-snow.jpg);
background-size: cover;
-moz-background-size: cover;
}
.carousel .three {
background-image: url(../images/auto-sunset.jpg);
background-size: cover;
-moz-background-size: cover;
}
.carousel .contactPg {
background-image: url(../images/contact-mando-auto-parts.jpg);
background-size: cover;
-moz-background-size: cover;
}
.carousel .active {
opacity: 1 !important;
}
.carousel .left {
opacity: 1 !important;
-webkit-transition: opacity 0.5s !important;
-moz-transition: opacity 0.5s !important;
-ms-transition: opacity 0.5s !important;
-o-transition: opacity 0.5s !important;
transition: opacity 0.5s !important;
}
@media (max-width:767px) {
#myCarousel {
display:none !important;
}
}
.navbar-custom {
color: #FFFFFF;
background-color: #0d4ea2;
text-align: center;
border:0;
font-size: 100%;
}
.navbar-header {
padding-right: 5%;
}
<body>
<div class="container-fluid">
<div class="row"></div>
</div>
<div class="container">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="active item one"></div>
<div class="item two"></div>
<div class="item three"></div>
</div>
</div>
<nav class="navbar navbar-default navbar-custom">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#defaultNavbar1"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>
<a href="index.html"><img src="images/mando-logo.png" alt="Mando Auto Parts" /></a></div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="defaultNavbar1">
<ul class="nav navbar-nav">
<li class="active"><a href="index.html">HOME<span class="sr-only">(current)</span></a></li>
<li><a href="http://www.mandocatalog.com/" target="_blank">CATALOG</a></li>
<li><a href="http://mandoautoparts.com/blog/" target="_blank">ANNOUNCEMENTS</a></li>
<li class="dropdown"><a href="mando-auto-part-products.html" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">PRODUCTS<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="mando-auto-part-products.html#abs">ABS Sensor</a></li>
<li><a href="mando-auto-part-products.html#accomp">A/C Compressor</a></li>
<li><a href="mando-auto-part-products.html#alternator">Alternators</a></li>
<li><a href="mando-auto-part-products.html#brakebooster">Brake Boosters</a></li>
<li><a href="mando-auto-part-products.html#calipers">Calipers</a></li>
<li><a href="mando-auto-part-products.html#ignitioncoils">Ignition Coils</a></li>
<li><a href="mando-auto-part-products.html#mastercylinder">Master Cyclinder</a></li>
<li><a href="mando-auto-part-products.html#oxygen">Oxygen Sensor</a></li>
<li><a href="mando-auto-part-products.html#steeringpump">Power Steering Pumps</a></li>
<li><a href="mando-auto-part-products.html#rack">Rack and Pinion</a></li>
<li><a href="mando-auto-part-products.html#shocks">Shocks and Struts</a></li>
<li><a href="mando-auto-part-products.html#starter">Starters</a></li>
</ul>
</li>
<li><a href="contact-mando-auto-parts.html">CONTACT</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
答案 0 :(得分:0)
在此处移除.container
课程,或在.container
之外移动导航栏部分。您已将导航栏部分放在.container
<body>
<div class="container">
<!-- carousel -->
<!-- nav section -->
</div>
</body>
将导航栏部分移到 .container div
之外 <body>
<!-- nav section --> move it outside container and add container instead of container-fluid inside the navbar
<nav class="navbar navbar-default navbar-custom">
<div class="container">
</div>
</nav>
<div class="container">
<!-- carousel -->
</div>
</body>
希望这项工作