gpt4 book ai didi

html - 图像上的中心跨度类元素

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

试图让 span 元素显示在我的图像的中心,以创建一个交互式按钮。 Span 类是显示在图像左上角的“plus_own”元素。

.plus_own {
font-size: 70px;
color: white;
font-family: unc;
position: relative;
font-weight: bold;
top: -30px;
transition: all 0.4s ease;
}

尝试创建交互式按钮的居中 span 类元素。

最佳答案

我建议您查看 this 以更好地了解其工作原理。

我建议的做法是这样的:

.container {
position: relative;
text-align: center;
color: white;
}

.plus_own {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: red;
font-weight: bold;
}
<div class="container">
<img src="https://cdn.shopify.com/s/files/1/1330/4567/files/DSC_0838_1024x1024.jpg?v=1522089465" style="width:100%;">
<span class="plus_own">Some Text</span>
</div>

关于html - 图像上的中心跨度类元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55367997/

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