css - IE8 : what to use in place of nth-of-type(n)?

标签 css internet-explorer-8 css-selectors

我继承了以下 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/

相关文章:

html - 如何使用 bootstrap 格式化文本以换行到第二行?

css - 如何应用像:hover to ng2 pseudo class :host这样的伪类

javascript - 我无法处理多个复选框,我不知道出了什么问题

javascript - 无法滚动页面时隐藏div,有滚动条需要滚动页面时显示div

Javascript:选择时切换文本

css - Internet Explorer 8 中生成内容的文本对齐

javascript - Twitter 按钮在 IE8 中导致 JS 错误(预期标识符)

javascript - 视频 JS 就绪事件和 IE8

css - 按类别选择除最后一个以外的所有类别

html - 我可以在 CSS 中对子元素进行分组吗?