/* 选择第 n 个元素的示例代码 */
/* 选择第 3 个子元素 */
:nth-child(3) {
background-color: yellow;
}
/* 选择第 2 个偶数元素 */
:nth-of-type(2n) {
color: red;
}
/* 选择第 1 个奇数元素 */
:nth-of-type(2n+1) {
font-weight: bold;
}
:nth-child(n)
:选择父元素下的第 n 个子元素,无论其类型。:nth-of-type(n)
:选择父元素下的第 n 个特定类型的子元素。2n
表示偶数,2n+1
表示奇数。上一篇:css横向滚动条
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站