css 水平垂直居中

1.

 display: flex;
 justify-content: center;
 align-items: center;
<!-- HTML -->
<div class="flex__container">
    <div class="flex__item"></div>
</div>

/* CSS */
.flex__container {
    display: flex;
    justify-content: center;
    align-items: center;
}

2.position: abolute;

left: 50%;

top: 50%;

transform: translate(-50%, -50%);

posted @ 2020-07-20 10:29  氧化成风  阅读(89)  评论(0编辑  收藏  举报