flex box 的基础使用

flex box兼容性并不是非常好在各个浏览器上特别是ie,以及微信浏览器上的兼容性就。。。。。。。。。。。。。。。。。


demo【此案例在ie浏览器上就会不兼容】

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <style>
        .father{
            width: 100%;
            height: 300px;
            background-color: #29ABE2;
            display: flex;
            align-items: center;
            flex-direction: row;
            flex-flow: row wrap;
        }
        .son{
            height: 100px;
            background-color:#FF4500 ;
            flex: 1;    
        }
    </style>
    <body>
        <div class="father"><div class="son" style="background:#8B008B"></div><div class="son"></div><div class="son" style="background-color: #3A3A3A;"></div>  </div>
    </body>
</html>

更改方案
(不过如果要使用最好只是使用它的基础等比分配,其他新旧属性对应复杂,通常一个属性就需要多条重复,才能满足)

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <style>



        .father{
            width: 100%;
            background-color: #29ABE2;
            display:-ms-flexbox;
            display: flex;
            align-items: center;
            flex-direction:row;
            justify-content: space-between;
            flex-flow: row wrap;
        }
        .son{
            height: 100px;
            background-color:#FF4500 ;
            -ms-flex:2;
           -webkit-box-align:center;
            flex: 1;    
        }
    </style>
    <body>
        <div class="father"><div class="son"></div><div class="son" style="background-color: #3A3A3A;"></div><div class="son"></div><div class="son" style="background-color: #3A3A3A;"></div>   </div>
    </body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值