flex弹性盒模型

flex是弹性盒子,display:flex用来定义一个盒子的模型为弹性盒子,弹性盒子默认子元素的块级元素是并排展示的

display: flex;定义一个盒子,定义盒子是写在父盒子CSS上

/* 子元素的展示方式是垂直方向展示,row是默认水平方向展示 */
  flex-direction: row;
  flex-direction: column;
 /* 子元素的换行wrap是换行,nowrap是不换行 */
 flex-wrap: wrap;
 flex-wrap: nowrap;
 /* flex-flow是子元素的排列方向和换行的简写方式 */
  flex-flow:column wrap;

justify-content主轴

/* justify-content用来控制子元素在主轴上的排列方式justify-content有多个属性 */
 /*flex-start 默认起点位置排列 */
 justify-content: flex-start;
 /* flex-end紧靠盒子的终点 */
 justify-content: flex-end;
 /* center让子元素在盒子方向的居中,如果是子元素水平排列则水平居中,垂直排列则垂直居中 */
 justify-content: center;
 /* space-between元素两侧紧贴容器,中间元素平均分配 */
 justify-content: space-between;
 /* space-around元素两侧都有距离,元素与元素之间的距离是元素与容器之间距离大一倍 */
 justify-content: space-around;
 /* space-evenly元素间的距离平均分配 */
 justify-content: space-evenly;

align-items交叉轴

   align-items交叉轴方向上的排列 
    align-items: center;
    align-items: flex-end;
    align-items: flex-start;
    align-items: stretch;

align-content是设置元素在交叉轴上的对齐方式,只适用于多行,需要配合flex-wrap换行使用

   align-content: center;
   align-content: flex-end;
   align-content: flex-start;
   align-content: stretch;
.son {
  width: 100px;
  height: 100px;
  background: #fff56f;
  border: 1px solid;
  margin-bottom: 5px;
}
<body>
  <div class="father">
    <div class="son">1</div>
    <div class="son">2</div>
    <div class="son">3</div>
    <div class="son">4</div>
    <div class="son">5</div>
    <div class="son">6</div>


  </div>
</body>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值