display:table,布局自动分宽度

来源:互联网 发布:甘肃网络电视台回播 编辑:程序博客网 时间:2024/06/04 19:23

<!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>        * {            list-style: none;        }                ul {            width: 300px;            display: table;        }                ul li {            display: table-cell;            background: red;            height: 60px;        }                ul li:nth-child(2) {            background: yellow;        }                ul li:nth-child(4) {            background: yellow;        }    </style></head><body>    <ul>        <li>1</li>        <li>2</li>        <li>3</li>        <li>4</li>        <li>5</li>    </ul></body></html>


原创粉丝点击