agi*_*gis 2 css jquery twitter-bootstrap owl-carousel
我正在使用jQuery Owl Carousel我创建了一个图像滑块,我想在滑块图像上添加背景颜色。
2019 年注意事项:http://owlgraphic.com现在重定向到恶意网站。
这是标记:
<!-- HEADER-02 CONTENT -->
<div class="header-02-sub">
<!-- SLIDER STARTS HERE -->
<div id="owl-slider" class="owl-carousel owl-theme">
<div class="item">
<img src="http://placehold.it/1600x700" alt="The Last of us">
<div class="caption">
<h1>SOME TITLE HERE</h1>
</div>
</div>
<div class="item">
<img src="http://placehold.it/1600x700" alt="The Last of us">
<div class="caption">
<h1>SOME TITLE HERE</h1>
</div>
</div>
<div class="item">
<img src="http://placehold.it/1600x700" alt="The Last of us">
<div class="caption">
<h1>SOME TITLE HERE</h1>
</div>
</div>
</div>
<!-- SLIDER ENDS HERE -->
</div>
<!-- END HEADER-02 CONTENT -->
Run Code Online (Sandbox Code Playgroud)
我已经添加了这个CSS:
.header-02-sub {
background-color:red;
z-index:9999999;
witdth:100%;
height:100%;
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过将此代码添加到#owl-slider父级中,或者.item这些代码都不起作用。
这是一个jsbin
关于如何在幻灯片图像上添加背景颜色有什么建议吗?
添加一个绝对定位的 DIV(我们称之为.overlay)到.item元素中,然后用以下命令标记这个新的 DIV:
.overlay{
position: absolute;
top: 0px;
left: 0px;
height: 700px;
width: 1600px;
background-color: red;
opacity: 0.5;
}
Run Code Online (Sandbox Code Playgroud)
更新:
如果您的页面是响应式的,请添加position: relative高度和宽度.item,然后将其更改.overlay为 100%
.item{
position: relative;
}
.overlay{
position: absolute;
top: 0px;
left: 0px;
height: 100%;
width: 100%;
background-color: red;
opacity: 0.5;
}
Run Code Online (Sandbox Code Playgroud)