我在设置 owl carousel item
内容的 z-index 时遇到问题。
每个轮播元素都有背景图片和文本内容。
固定覆盖应该在元素(背景图像)上,但不在元素内容上。
固定覆盖不能成为轮播元素的一部分,它必须在幻灯片变化时保持静止。
我尝试了所有不同的方法,包括各种 z-index 值以及所有元素的不同定位,但都没有成功。
HTML、PHP:
<div class="intro">
<div class="owl-carousel owl-theme">
<?php
foreach ($Services as $key => $service) {
echo '<div class="item ' . $key .'" style="background: url(' . $css_path . $service->img_mainpage . '">';
echo '<div class="hdr_main"><a href="/' . slug($service->title) . '">' . $service->title . '</a></div>';
echo '<span class="about">' . $service->about . '</span>';
echo '</div>';
}
?>
</div>
<div class="fixed-overlay">
<?php include(__DIR__ . '/../../assets/gui/mainpage-polygon.svg'); ?>
</div>
</div>
CSS:
div.intro {
position: relative;
height: 100vh;
background: rgb(0, 121, 201);
}
div.intro .fixed-overlay {
position: absolute;
top: 0px;
left: 0px;
height: 100vh;
width: 60%;
z-index: 3;
}
.owl-carousel {
height: 100vh;
z-index: 2;
}
.owl-carousel .item {
height: 100vh;
display: flex;
justify-content: center;
flex-direction: column;
text-align: right;
padding-right: 13%;
background-repeat: no-repeat !important;
background-size: cover !important;
background-position: center center !important;
}
.item .hdr_main a {
z-index: 9999;
}
谢谢。
最佳答案
.item {
z-index: 1;
}
.owl-carousel {
z-index: -1;
}
试试这个
关于css - Owl Carousel 元素内容 z-index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44278473/