flex:1的各种算法看CSS精通精通那里面有

2020-10-28 14:51:56 浏览数 (1)

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>131-伸缩布局</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        ul{
            list-style: none;
            width: 600px;
            height: 600px;
            border: 1px solid #000;
            margin: 100px auto;
            display: flex;
        }
        ul>li {
            width: 100px;
            height: 100px;
            line-height: 100px;
            text-align: center;
            font-size: 30px;
            background: red;
        }
        ul>li:nth-child(1){
            /*
            flex: 扩充 缩小 宽度;
            flex默认值
            flex: 0 1 auto;
            */
            flex: 0 1 100px;
        }
        ul>li:nth-child(2){
            background: green;
            flex: 0 1 200px;
        }
        ul>li:nth-child(3){
            background: blue;
            flex: 0 1 300px;
        }
    </style>
</head>
<body>
<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
</ul>
</body>
</html>

0 人点赞