display:flex用法

flex属性:

display:flex      flex-direction: row | row-reverse | column | column-reverse;      

flex-wrap: nowrap | wrap | wrap-reverse;     justify-content: flex-start | flex-end | center | space-between | space-around;

基本代码:

<template>
 <div class="totalStyle">

   <div class="firstStyle">
     <div class="divStyle color1" >
     </div>
     <div class="divStyle color2" >
     </div>
     <div class="divStyle color3" >
     </div>
   </div>
 </div>
</template>
<style scoped lang="scss">
  .totalStyle{
    height:100%;
    width:100%;
  }

  .firstStyle{
    width:100%;
    height:300px;
    background-color: #DDA0DD;
    display: flex;
    flex-direction:row;
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .color1{
background-color: #AFEEEE;
  }

  .color2{
    background-color: #0000FF;
  }
  .color3{
    background-color: #BA55D3;
  }
  .divStyle1{
    width:200px;
    height: 200px;
  }
  .divStyle2{
    width:200px;
    height: 100px;
  }
  .divStyle3{
    width:200px;
    height: 50px;
  }
</style>

项目排列顺序:

1 flex:row;

父级模块中,子级项目按从左到右顺序排列;

2 flex:row-reverse;

父级模块中,子级项目按从右到左顺序排列;

3 flex:column;

父级模块中,子级项目按从上到下顺序排列;

4 flex:column-reverse;

父级模块中,子级项目按从下到上顺序排列;

 

项目排列方式:

1justify-content: center;

父级模块中,所有子级项目水平居中排列;

2 justify-content: flex-start;

父级模块中,所有子级项目左对齐;

2 justify-content: flex-end;

父级模块中,所有子级项目右对齐;

3 justify-content: space-between;

父级模块中,所有子级项目顺序排列,间隔相等;

4 justify-content: space-around;

父级模块中,所有子级项目两侧间隔相等;

项目排列是否huan'hang

1flex-wrap: nowrap;

不换行,会缩小项目宽度,来占据页面;

2flex-wrap: wrap;

换行显示,超过父级模块的也会显示

2flex-wrap: wrap-reverse;

换行显示,第一行在最下面

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值