微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

flex flex-grow的用法

<!doctype html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <Meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <Meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>flex-grow</title>
    <style>
        .Box {
            width: 560px;
            height: 500px;
            background-color: red;
            /*1.开启flex布局
                    flex:块级元素
                  inline-flex:行内元素 */
            display: flex;
        }
        .item {
            width: 100px;
            height: 100px;
        }
        .item1 {
            background-color: blue;
            height: 60px;
            /*(560-100*3 )*2/(2+2+3) = 74.29*/
            flex-grow: 2;

        }
        .item2 {
            background-color: #0f0;
            height: 150px;
            flex-grow: 2;

        }

        .item3 {
            background-color: #ccc;
            height: 120px;
            flex-grow: 3;

        }

    </style>
</head>
<body>
         <div class="Box">
             <div class="item item1">item1</div>
             <div class="item item2">item2</div>
             <div class="item item3">item3</div>
         </div>
</body>
</html>

  效果

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐