好 啊,
nth-child(n)
不能工作,(语法上也不正确
nth-child(1n+0)
,或
nth-of-type(1n+0)
). 那个(
An+B
input.tab
给第一个兄弟姐妹
div.tab_content
输入选项卡
到第二个
安+B
(后一种语法选择多个同级,而不是一个,而且表达式在选择器中出现两次并不意味着它只在
n
我看不出你想做什么的“干净”解决方案。您可能需要重新考虑整个策略,并使用不同的文档结构,仅使用一个选择器即可获得所需的内容,但是,如果使用一个规则和多个逗号分隔的选择器,则仍有可能实现显著的简化,例如:
.tab:checked:nth-of-type(1) ~ article .tab_content:nth-of-type(1),
.tab:checked:nth-of-type(2) ~ article .tab_content:nth-of-type(2),
.tab:checked:nth-of-type(3) ~ article .tab_content:nth-of-type(3) {
opacity: 1;
transition: 0.5s opacity ease-in, 0.8s transform ease;
position: relative;
top: 0;
z-index: 100;
transform: translateY(0px);
text-shadow: 0 0 0; }