3.伸縮佈局固定寬度

<!DOCTYPE html>
<html lang="en">
<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>
        section {
            width: 1000px;
            height: 200px;
            border:1px solid pink;
            margin:100px auto;
            display:flex;
        }
        section div {
            /* width:33.33%; */
            height:100%;
            float:left;
            /* flex:1;    */
            margin:0 5px;
            /* 子盒子添加份數 */
        }
        section div:nth-child(1) {
            background-color: pink;
            width: 300px;
            /* 子盒子份數  不跟單位*/
        }
        section div:nth-child(2) {
            background-color: green;
            width: 100px;
        }
        section div:nth-child(3) {
            background-color: pink;
            flex:1;
        }

        section div:nth-child(4) {
            background-color: skyblue;
            flex:1;
        }
    </style>

</head>
<body>
    <section>
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
    </section>
</body>
</html>

2個盒子固定 不影響剩下的盒子,剩下的盒子再去平均分

伸縮時固定像素的盒子不變

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章