gpt4 book ai didi

jquery - 在 Owl Carousel 图像上添加背景颜色

转载 作者:行者123 更新时间:2023-11-28 11:09:31 26 4
gpt4 key购买 nike

我正在使用 jQuery Owl Carousel 并且我创建了一个图像 slider ,我想在 slider 图像上添加背景颜色。

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 -->

我已经添加了这个 CSS :

.header-02-sub {
background-color:red;
z-index:9999999;
witdth:100%;
height:100%;
}

我也尝试过将此代码添加到 #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;
}

更新:

如果您的页面是响应式的,请将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;
}

New JSBin

关于jquery - 在 Owl Carousel 图像上添加背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25185653/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com