gpt4 book ai didi

css - SCSS 嵌套 nth-of-type

转载 作者:太空宇宙 更新时间:2023-11-03 21:18:04 25 4
gpt4 key购买 nike

使用 SCSS 并有一个嵌套元素,我试图将 nth-of-type() 规则嵌套到其中,但无论如何我输入它都没有用。我希望每个奇数 el_header 元素都是白色文本,每个偶数元素都是黑色。

.el {
height: 500px;
width: 500px;

&_header {
height: 100%;
width: 10%;
background: #555;
display: inline-block;
line-height: 500px;
text-align: center;

&nth-of-type(odd) {
color: black;
}
&nth-of-type(even) {
color: white;
}

}
}

DEMO

最佳答案

你刚刚忘记了 :& 之后。

使用

&:nth-of-type(odd){...}

&:nth-of-type(even){...}

它会起作用的。参见 updated fiddle

关于css - SCSS 嵌套 nth-of-type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40116794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com