ckecked元素编号:nth-child css规则 [英] ckecked element number in :nth-child css rule
本文介绍了ckecked元素编号:nth-child css规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的页面和一些部分上有一些单选按钮。
< input id =tab1type = radioname =responsive-tabsclass =responsive-selectchecked>
< input id =tab2type =radioname =responsive-tabsclass =responsive-select>
< section id =content1>
某些内容
< / section>
< section id =content2>
某些内容
< / section>
当选择第n个单选按钮时,我需要第n个节。
当然,它很容易实现通过使用jquery,但我想通过css只这样做,所以请帮助我。现在我这样做这样
#tab1:checked〜#content1,
#tab2:checked〜
#tab3:checked〜#content3,
#tab4:checked〜#content4 {
display:block;
}
但我希望这个css规则更灵活和独立于元素计数。
解决方案
您可以使用:target
pseudoclass