css 两列宽度固定,一列自适应

直接上代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #main {
            display: flex;
            /*设为伸缩容器*/
        }

        #left {
            width: 200px;
            /*左侧固定宽度*/
            height: 400px;
            background: aqua;
        }

        #center {
            width: 200px;
            /*固定右侧宽度*/
            height: 400px;
            background: blue;
        }

        #right {
            flex-grow: 1;
            /*填满剩余空间*/
            height: 400px;
            background: green;
        }
    </style>
</head>
<body>
<div id="main">
    <div id="left"></div>
    <div id="center"></div>
    <div id="right"></div>
</div>
</body>
</html>

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×