![]() |
踏实的烤地瓜 · CSS的:nth-child选择器:如何选择 ...· 1 月前 · |
![]() |
爱听歌的鞭炮 · 【现代 CSS】标准滚动条控制规范 ...· 1 周前 · |
![]() |
睿智的眼镜 · CAD中一些特殊符号怎么输入?【AutoCA ...· 8 月前 · |
![]() |
打盹的针织衫 · 喜报!光山这些学校、老师、学生荣获信阳市第二 ...· 8 月前 · |
![]() |
瘦瘦的西瓜 · 分享 | 有哪些免费好用的WiFi工具? - 知乎· 1 年前 · |
![]() |
千杯不醉的海龟 · 岳雲鵬臉上長瘤欲手術 暫別舞台將有面癱風險/ ...· 1 年前 · |
![]() |
果断的甘蔗 · 2023款理想l9和22款区别 - 抖音· 1 年前 · |
<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