【问题标题】:CSS Selector, Select a class except the first occurrence of that classCSS 选择器,选择除第一次出现该类以外的类
【发布时间】:2014-01-23 08:46:21
【问题描述】:

试图选择一个类,但该类的第一次出现除外。 为什么这不起作用

.myClass:not(.myClass:first)

ps只有css没有jquery,这个是用jqueryHow to select all except the first occurence of a class

【问题讨论】:

    标签: css css-selectors


    【解决方案1】:

    使用nth-child

    .myClass:nth-child(n+2) {
            //style here
        }
    

    这里是Demo

    【讨论】:

    • 我猜first occurrence 不代表first-child
    • 如果它们有不同的父元素怎么办? ) 像这样:jsfiddle.net/aFJVq/1
    猜你喜欢
    • 2012-02-07
    • 2013-01-10
    • 2011-09-30
    • 1970-01-01
    • 2011-04-06
    • 2011-02-18
    • 2019-05-16
    • 1970-01-01
    • 2015-05-01
    相关资源
    最近更新 更多