您好,欢迎来到外链网!
当前位置:外链网 » 站长资讯 » 专业问答 » 文章详细 订阅RssFeed

flex布局水平方向均匀分布,flex实现水平垂直居中

来源:互联网 浏览:71次 时间:2023-04-08

效果如下:

实现代码:

通过给父元素设置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;}

?