
一、可以利用flex来布局一个p在另一个p里面水平垂直居中
如:html代码:
<p class="container"> <p class="box"> </p> </p>
css代码:
.container{
width:600px;
height:400px;
border:1px solid blue;
display: flex;
justify-content:center;
align-items:center;
}
.box{
width:200px;
height:100px;
border:1px red solid;ps:这样就可以水平垂直居中咯
立即学习“前端免费学习笔记(深入)”;
二、flex的属性
<p class="items"> <p class="item">1</p> <p class="item">23</p> <p class="item">4</p> </p>
可以写在items上的属性有六个:
•flex-direction
•flex-wrap
•flex-flow
•justify-content
•align-items
•align-content
可以写在item上的有6个:
•order//这个就是item单独给了,要是想让那个item调换顺序就给这个属性给那个item
•flex-grow
•flex-shrink
•flex-basis
•flex
•align-self
以上就是CSS Flex 的用途详解的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号