gpt4 book ai didi

html - 按钮没有出现在图像前面

转载 作者:太空宇宙 更新时间:2023-11-04 06:51:44 25 4
gpt4 key购买 nike

我已经放置了我的按钮,但我希​​望 int 位于图像之上,但出于某种原因 z-index: 1; 无法正常工作。我还尝试了每个 position 属性以查看它是否有效,但没有任何变化,我尝试将 z-index 添加到下面的所有 css 代码中,但没有任何效果我搜索了互联网,包括 YouTube,并尝试了那里的方法,但似乎没有任何效果。

我的 HTML 代码如下:

a .play {
background: steelblue;
border-radius: 50% / 10%;
color: #FFFFFF;
font-size: 2em;
height: 3em;
margin-top: -350px;
float: right;
margin-right: 10px;
margin-top: 25px;
padding: 0;
position: relative;
z-index: 1;
text-align: center;
text-indent: 0.1em;
transition: all 150ms ease-out;
width: 4em;
}

a .play:hover {
background: #ff0000;
}

a .play::before {
background: inherit;
border-radius: 5% / 50%;
bottom: 9%;
content: "";
left: -5%;
position: absolute;
right: -5%;
top: 9%;
}

a .play::after {
border-style: solid;
border-width: 1em 0 1em 1.732em;
border-color: transparent transparent transparent rgba(255, 255, 255, 0.75);
content: ' ';
font-size: 0.75em;
height: 0;
margin: -1em 0 0 -0.75em;
top: 50%;
position: absolute;
width: 0;
}
<div id="index-gallery">
<div class="item">
<img src="img/after.jpg" alt="" width="300px" />
<p>My Caption here</p>
<a href="#">
<div class="play"></div>
</a>
</div>
<div class="item2">
<img src="img/after.jpg" alt="" width="300px" />
<p>My Caption here</p>
<a href="#">
<div class="play2"></div>
</a>
</div>
<div class="item3">
<img src="img/after.jpg" alt="" width="300px" />
<p>My Caption here</p>
<a href="#">
<div class="play3"></div>
</a>
</div>
<div class="item4">
<img src="img/after.jpg" alt="" width="300px" />
<p>My Caption here</p>
<a href="#">
<div class="play4"></div>
</a>
</div>
</div>

Button not appearing on top of image

最佳答案

试试这个:

div.item {
position: relative;
}

a.button-wrapper {
display: block;
height: 100px;
position: absolute;
top: 16px;
left: 80px;
}

a .play {
background: steelblue;
border-radius: 50% / 10%;
color: #FFFFFF;
font-size: 2em;
height: 3em;
float: left;
margin-right: 10px;
margin-top: 0;
padding: 0;
position: relative;
z-index: 1;
text-align: center;
text-indent: 0.1em;
transition: all 150ms ease-out;
width: 4em;
}

a .play:hover {
background: #ff0000;
}

a .play::before {
background: inherit;
border-radius: 5% / 50%;
bottom: 9%;
content: "";
left: -5%;
position: absolute;
right: -5%;
top: 9%;
}

a .play::after {
border-style: solid;
border-width: 1em 0 1em 1.732em;
border-color: transparent transparent transparent rgba(255, 255, 255, 0.75);
content: ' ';
font-size: 0.75em;
height: 0;
margin: -1em 0 0 -0.75em;
top: 50%;
position: absolute;
width: 0;
}
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<div id="index-gallery">
<div class="item">
<img src="https://via.placeholder.com/350x150" alt="" width="300px" />
<p>My Caption here</p>
<a href="#" class="button-wrapper">
<div class="play"></div>
</a>
</div>
<div class="item">
<img src="https://via.placeholder.com/350x150" alt="" width="300px" />
<p>My Caption here</p>
<a href="#" class="button-wrapper">
<div class="play"></div>
</a>
</div>
<div class="item">
<img src="https://via.placeholder.com/350x150" alt="" width="300px" />
<p>My Caption here</p>
<a href="#" class="button-wrapper">
<div class="play"></div>
</a>
</div>
<div class="item">
<img src="https://via.placeholder.com/350x150" alt="" width="300px" />
<p>My Caption here</p>
<a href="#" class="button-wrapper">
<div class="play"></div>
</a>
</div>
</body>
</html>

关于html - 按钮没有出现在图像前面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52809088/

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