乐趣区

关于css3:flex实现左右均分布局带固定间距

1. 间接上代码

<!DOCTYPE html>
<html lang="zh">

    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>Document</title>
        <style>
            body,
            p {margin: 0;}
            
            .parent {display: flex;}
            
            .child {
                flex: 1;
                height: 100px;
            }
            
            .child {margin-right: 14px;}
            
            .child:last-child {margin-right: 0;}
        </style>
    </head>

    <body>
        <div class="parent" style="background-color: #ffff;">
            <div class="child" style="background-color: #1180FD;"></div>
            <div class="child" style="background-color: #1180FD;"></div>
            <div class="child" style="background-color: #1180FD;"></div>
            <div class="child" style="background-color: #1180FD;"></div>
        </div>
    </body>

</html>

2. 成果展现

退出移动版