


我一般写居中都是这样写:
.wrap{position:relative;}
.img{position:absolute; left:50%; top:50%; margin-left:-width/2; margin-top:-height/2;}
1、请问百度云盘怎么计算的left和top值
2、我这种写法有什么弊端,是否可以替换百度的这种写法?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
估计是用js通过容器宽高和自身宽高算的。
你的有什么弊端不清楚。
对于ie8以上能保证子元素比其容器小我一般这么写
后六个可以提出来做一个叫
.center的做居中的样式你的弊端应该是 dom 的长和宽必须是指定的。
可以试试
transform: translate(-50%, -50%);dom结构:
css: