目前我的轮播似乎已经到了页面顶部。我正在使用导航栏固定顶部,所以显然导航栏隐藏了旋转木马的顶部。我怎样才能使旋转木马直接固定在导航栏下方?添加简单的填充不会像使用较小的屏幕那样工作,导航栏会折叠,并且与未折叠时的高度略有不同。
代码:
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="container">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img src="/images/p51blueprint.jpg" alt="P-51" width="100%">
</div>
<div class="item">
<img src="/images/f-18-hornet.jpg" alt="F-18" width="100%">
</div>
<div class="item">
<img src="/images/p51blackandwhite.jpg" alt="P-51" width="100%">
</div>
<div class="item">
<img src="/images/B-52-Stratofortress-infographic.jpg" alt="B-52" width="100%">
</div>
</div>
</div>
<!-- Control arrows -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
答案 0 :(得分:0)
已知导航栏覆盖网站的内容,因此更改主体的填充,然后使用媒体查询来更改主体的填充以获得不同的大小。有点像:
body {
padding-top: 70px;
}
@media screen and (min-width:768px) and (max-width:990px) {
body {
margin-top:100px;
}
}
@media screen and (min-width:991px) and (max-width:1200px) {
body {
margin-top:70px;
}
}