我继承了以下 CSS 代码,最初隐藏了一系列段落和一系列列表项的后面的元素。
.profileSection p:nth-of-type(n+2) {
display: none;
}
.profileSection li:nth-of-type(n+6) {
display: none;
}
显然,这段代码在 IE8 中不起作用。隐藏这些元素的替代方法是什么?
最佳答案
下面是关于它的讨论:
http://www.thebrightlines.com/2010/01/04/alternative-for-nth-of-type-and-nth-child/
作者提到你可以通过使用引用特定的子元素
tagname + tagname + etc
或者通过使用
获取通用子项* + * + etc
我个人只会为这些元素添加一个特殊的类。
关于css - IE8 : what to use in place of nth-of-type(n)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13828644/