【问题标题】:select the last article inside of a section if it is odd [duplicate]如果它是奇数,则选择部分内的最后一篇文章[重复]
【发布时间】:2014-04-11 21:40:31
【问题描述】:

如果是奇数,是否可以选择本版块中的最后一篇文章?

<section>
    <article></article>
    <article></article>
    <article></article>
</section>

我正在尝试使用 :nth-last-of-type 选择器来做到这一点

【问题讨论】:

  • 你做了哪些努力?这是可能的。
  • 奇数是什么意思?
  • 你见过 :last-child 选择器吗?

标签: html css selector


【解决方案1】:

Demo Fiddle

您可以简单地使用 CSS,例如:

article:last-child:nth-child(odd){
    color:red;
}

【讨论】:

    猜你喜欢
    • 2014-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-12
    相关资源
    最近更新 更多