【问题标题】:Why does this li:last-child not work?为什么这个 li:last-child 不起作用?
【发布时间】:2012-09-06 01:40:01
【问题描述】:

我的 CSS 规则:

#menu-right li:last-child a, #menu-left li:last-child a, #menu-bottom li:last-child a, {
    border: none;
}

经过一些更改后停止工作,谁能告诉我为什么?测试网站已[移除]

谢谢!

【问题讨论】:

  • 在该页面上很难找到您正在谈论的元素。您可以使用jsfiddle.net 创建一个示例吗? (无需 JS)。

标签: css wordpress css-selectors


【解决方案1】:

您的规则有误。 { 之前不应有,(逗号):

替换:

#menu-bottom li:last-child a, {

与:

#menu-bottom li:last-child a {

另请注意,:last-child 选择器不适用于 Internet Explorer 6、7 和 8!

【讨论】:

  • :last-child 伪类仍然不能可靠地跨浏览器使用。特别是,Internet Explorer 版本 don't support it,尽管 Internet Explorer 7 和 Safari 3.2 确实 支持 :first-child,奇怪的是。
  • 啊。谢谢!那我就换第一个孩子。
  • 遇到同样问题的哥们,最后全部改成first-child。 :)
【解决方案2】:

#menu-bottom li:last-child a, { 替换为#menu-bottom li:last-child a {。您的规则中有一个逗号违反了它。

【讨论】:

    猜你喜欢
    • 2012-06-03
    • 1970-01-01
    • 2016-05-27
    • 1970-01-01
    • 1970-01-01
    • 2011-03-20
    • 2017-06-11
    • 1970-01-01
    • 2011-04-06
    相关资源
    最近更新 更多