300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 通过Flex布局设置水平垂直居中

通过Flex布局设置水平垂直居中

时间:2024-04-02 01:55:52

相关推荐

通过Flex布局设置水平垂直居中

效果如下:

实现代码:

通过给父元素设置CSS样式:

display:flex;

align-items:center;

justify-content:center;

//HTML<div class='box'><div class='box-item'></div></div>//css.box{display:flex;align-items:center;justify-content:center;height:100%;background:white;}.box-item{height:200px;width:200px;background:red;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。