【发布时间】:2016-10-27 06:48:39
【问题描述】:
我的 Bootstrap Carousel 出现问题。问题是在使用 css 进行转换期间,一张幻灯片和另一张幻灯片之间的布局。在一秒钟内,仅对一小部分背景,将初始 css 样式重新应用于文本和背景。
@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
/*carousel*/
.absolute {
margin-bottom: -46px;
text-align: center;
top: 250px;
position: relative;
z-index: 100;
color: white;
text-transform: uppercase;
font-size: 3em;
}
.index .item.active {
height: 450px;
background-image: url(images/first-back.jpg);
background-position: 0 5%;
background-repeat: no-repeat;
background-size: cover;
background-color: rgba(51, 51, 51, 0.34);
background-blend-mode: multiply;
}
.carousel-inner .item:nth-child(2) {
background: url(images/ac-bottom.jpg);
height: 450px;
background-size: cover;
background-repeat: no-repeat;
background-position: 0 52%;
background-color: rgba(51, 51, 51, 0.34);
background-blend-mode: multiply;
}
.carousel-inner .item:nth-child(3) {
background: url(images/grills-slider.jpg);
height: 450px;
background-size: cover;
background-repeat: no-repeat;
background-position: 0 52%;
background-color: rgba(51, 51, 51, 0.34);
background-blend-mode: multiply;
}
.carousel-inner .item:nth-child(4) {
background: url(images/store.jpg);
height: 450px;
background-size: cover;
background-repeat: no-repeat;
background-position: 0 52%;
background-color: rgba(51, 51, 51, 0.34);
background-blend-mode: multiply;
}
.index .item:nth-child(4) h1 {
text-decoration: underline;
}
.item.active h1 {
font-size: 2em;
color: white;
text-align: center;
position: relative;
top: 66%;
text-transform: uppercase;
}
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<h1>Is relaxing</h1>
</div>
<div class="item">
<h1>IS PEACE OF MIND</h1>
</div>
<div class="item">
<h1>IS CONFIDENCE</h1>
</div>
<div class="item">
<h1>STARTS HERE</h1>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
如您所见,我在 html 中使用的是背景图片而不是普通标签。最后一件事,我在轮播外使用h1
<h1 class="absolute">COMFORT</h1>
这将保持固定,用于布局目的。
提前谢谢你
【问题讨论】:
标签: css twitter-bootstrap-3 css-transitions carousel