CSS:定位盒子 水平垂直居中对齐 的最好写法

div{

width:200px;

height:100px;

position:absolute;

left:50%;  /*以父级宽度为准*/

top:50%;

translate:transform(-50%,-50%); /*以自身宽度为准*/

}

发布了70 篇原创文章 · 获赞 23 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/tiandaochouqin_1/article/details/88314523