在此之前元素垂直居中我使用的是绝对定位absolute或固定定位fixed
如何用flex实现元素垂直居中呢,父级包括子级
<div class='itemBox'>
<div>boxboxboxboxboxboxboxboxboxboxbox</div>
</div>
.itemBox{
display: flex;
justify-content: center;
align-items: center;
background: #588cfe;
width: 100%;
height: 100vh;
}
.itemBox p{
background: #ffffff;
width: 200px;
height: 200px;
word-break: break-all;//英文超出盒子不换行问题
}相关文章推荐:
CSS中text-transform属性实现字符串转换的代码
CSS中table表格的两种使用方法(实例)
Copyright © 2019- kushenhuo.cn 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务