less 定义 flex兼容样式

定义一套flex的 弹性盒兼容     引用之后直接传入参数就可以实现 

 /* 基本弹性盒子 */
 .demo{
    display: -webkit-box; /* Chrome 4+, Safari 3.1, iOS Safari 3.2+ */  
    display: -moz-box; /* Firefox 17- */  
    display: -webkit-flex; /* Chrome 21+, Safari 6.1+, iOS Safari 7+, Opera 15/16 */  
    display: -moz-flex; /* Firefox 18+ */  
    display: -ms-flexbox; /* IE 10 */  
    display: flex; /* Chrome 29+, Firefox 22+, IE 11+, Opera 12.1/17/18, Android 4.4+ */
}

// 定义主轴方向
.direction(@type:row){
    -webkit-box-orient: vertical;
    -ms-flex-direction: @type;
    -webkit-flex-direction: @type;
    flex-direction: @type;
}

// 定义垂直位置
.align(@type){
    -webkit-box-align: @type;
    -ms-flex-align: @type;
    -webkit-align-items: @type;
    align-items: @type;
}

// 定义横向位置
.justify(@type){
    -webkit-box-pack: @type;
    -ms-flex-pack: @type;
    -webkit-justify-content: @type;
    justify-content: @type;
}

// 定义换行
.wrap(@type){
    -webkit-flex-wrap: @type;
    -moz-flex-wrap: @type;
    -ms-flex-wrap: @type;
    -o-flex-wrap: @type;
    flex-wrap:  @type;
}

/* 方向 横向*/
.directionrow{
    .direction
}

/* 方向 竖向*/
.directioncol{
    .direction(column)
}

/* 竖向剧中 */
.align{
    // .align(flex-start)
    .align(center)
    // .align(flex-end)
}

/* 横向剧中 */
.justify{
    // .justify(flex-start);
    .justify(center);
    // .justify(flex-end);
    // 两边靠边  其余平分
    // .justify(space-between);
    // 剩余空间平分 加到盒子的间隙  不相等
    // .justify(space-around);
    // 剩余空间完全平分   盒子间距 完全相等
    // .justify(space-evenly)
}

/* 换行 */
.wrap{
   .wrap(wrap)
//    .wrap(nowrap)
//    .wrap(wrap-reverse)
}

/* 自适应 */
.flex{
    width: 0;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    -webkit-flex: 1;
    flex: 1;
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值