方法1
#child { position: absolute;
top:50%; left: 50%;
transform : translate(-50%,-50%);
}
方法2 flex
#parent {
justify-content: center; /*子元素水平居中 */
align-items:center; /* 子元素垂直居中 */
display: flex;
}
CSS3 不定宽高水平居中
最新推荐文章于 2020-12-23 18:40:15 发布