![]() |
踏实的烤地瓜 · CSS的:nth-child选择器:如何选择 ...· 3 月前 · |
![]() |
爱听歌的鞭炮 · 【现代 CSS】标准滚动条控制规范 ...· 2 月前 · |
![]() |
魁梧的硬币 · @document - CSS:层叠样式表 ...· 1 月前 · |
![]() |
爱搭讪的猴子 · print-color-adjust - ...· 1 月前 · |
![]() |
坚韧的绿茶 · OpenCV with Java: ...· 1 月前 · |
![]() |
聪明的消防车 · 我用KEIL编C语言的程序,用到了一个ato ...· 1 年前 · |
![]() |
有腹肌的大白菜 · eclipse学java选哪个安装-掘金· 1 年前 · |
![]() |
焦虑的皮带 · web打开在线的pdf文件,禁用打印和下载功 ...· 1 年前 · |
![]() |
儒雅的梨子 · TypeScript里一些特殊的类型 - ...· 2 年前 · |
<style>
.container {
width: 100%;
display: grid;
/*grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));*/
/*以防万一,子项不足占据一行时*/
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
grid-template-rows: 250px;
grid-auto-flow: row;
grid-auto-rows: 250px;
gap: 10px;
.container .item:nth-child(even) {
background-color: skyblue;
.container .item:nth-child(odd) {
background-color: pink;
</style>
<div class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</body>
原文链接: https://www.arryblog.com/guide/css3/defensive-css.html