zoukankan      html  css  js  c++  java
  • :nth-last-of-type (Selectors) – CSS 中文开发手册

    [
  •   CSS 中文开发手册

    :nth-last-of-type (Selectors) - CSS 中文开发手册

    该:nth-last-of-type(an+b)CSS伪类匹配的是在它之后有an+b-1个同类型同胞元素的元素,其中n的是正数或零。它本质上与:nth-of-type是一样的,除了它从后向前计数项目,而不是从前往后。

    /* Selects every fourth <div> inside a parent element */
    /* Counting backwards from the last one */
    div:nth-last-of-type(4n) {
      background-color: lime;
    }

    请参阅有关:nth-child的文档寻求更全面的描述。

    语法

    :nth-last-of-type( <nth> )where 
    <nth> = <an-plus-b> | even | odd

    实例

    HTML

    <div>
      <span>This is a span.</span>
      <span>This is another span.</span>
      <em>This is emphasized.</em>
      <span>Wow, this span gets limed!!!</span>
      <strike>This is struck through.</strike>
      <span>Here is one last span.</span>
    </div>

    CSS

    span:nth-last-of-type(2) {
      background-color: lime;
    }

    结果

    规范

    Specification

    Status

    Comment

    Selectors Level 4The definition of ':nth-last-of-type' in that specification.

    Working Draft

    Matching elements are not required to have a parent.

    Selectors Level 3The definition of ':nth-last-of-type' in that specification.

    Recommendation

    Initial definition.

    浏览器兼容性

    Feature

    Chrome

    Edge

    Firefox (Gecko)

    Internet Explorer

    Opera

    Safari

    Basic support

    4.0

    (Yes)

    3.5 (1.9.1)

    9.0

    9.5

    3.2

    Feature

    Android

    Edge

    Firefox Mobile (Gecko)

    IE Mobile

    Opera Mobile

    Safari Mobile

    Basic support

    2.1

    (Yes)

    1.0 (1.9.1)

    9.0

    10.0

    3.2

  •   CSS 中文开发手册
    ]
    转载请保留页面地址:https://www.breakyizhan.com/css/31249.html
  • 相关阅读:
    异步编程
    写代码写至最有面向对象味道
    GitHub上整理
    用CQRS+ES实现DDD
    前端开发
    让低版本的IE浏览器 强制渲染为IE8 或者 以上 浏览器模式
    NHibernate系列
    hadoop搭建开发环境及编写Hello World
    Linux date -s(转)
    即时编译和打包您的 Groovy 脚本(转)
  • 原文地址:https://www.cnblogs.com/breakyizhan/p/13252680.html
Copyright © 2011-2022 走看看