gpt4 book ai didi

css - 如何用图标覆盖图像

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

这是例子 https://jsbin.com/rekaxa/edit?html,css,output .我想把那个红色圆圈(一个图标)放在图像上,但要保持 html 简单明了。实现它的最佳方式(也许完全不同)是什么?

最佳答案

你还没有说你想要图标在哪里,所以我选择了 div 的死点。

div {
background-color: green;
width: 280px;
height: 180px;
position: relative;
}
img {
margin: 0 auto;
display: block;
}
div:after {
content: '';
position: absolute;
top: 50%; /* adjust as requiured */
left: 50%; /* adjust as required */
margin-top: -15px;
margin-left: -15px;
width: 30px;
height: 30px;
background: red;
display: block;
border-radius: 15px;
}
<div class="icon">
<img src="http://dummyimage.com/200x150/000/fff" />
</div>

关于css - 如何用图标覆盖图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31314787/

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