为了能到远方,脚下的每一步都不能少.|

CSS水平垂直居中

  1. 使用flex布局
<div class="content">
<div class="box">
</div>
</div>
.content{
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}

【注意】若垂直居中失效,是因为content盒子缺少高度,height:100%无法撑开盒子

本文作者:Morita-desin

本文链接:https://www.cnblogs.com/yqquinn/p/17777137.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   Morita-desin  阅读(4)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起