//left: 50%;
//top: 50%;
//transform: translate(-50%, -50%);
//这三个是使用绝对定位后使其居中的解决方法
.sp-wrap-img.theme-list .yishouwan {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 130px;
height: 100px;
z-index: 999;
opacity: 0.5;
}
使用了绝对定位如何居中
最新推荐文章于 2023-04-12 14:31:51 发布
本文介绍了一种使用CSS的绝对定位使元素居中的方法,通过设置left, top属性为50%,并结合transform: translate(-50%, -50%)实现精确居中。这种方法广泛应用于网页布局中,特别是在响应式设计和主题列表展示时。

1万+

被折叠的 条评论
为什么被折叠?



