TypechoJoeTheme

Dcr163的博客

统计

CSS3 nth-last-of-type(n)选择器

2017-03-09
/
0 评论
/
726 阅读
/
正在检测是否收录...
03/09

    :nth-last-of-type(n)”选择器和“:nth-of-type(n)”选择器是一样的,选择父元素中指定的某种子元素类型,但它的起始方向是从最后一个子元素开始,而且它的使用方法类似于“:nth-last-child(n)”选择器一样。

例如:将容器“div.wrapper”中倒数第五个Div元素背景设置为橙色。

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8">
<title>nth-last-of-type(n)</title>
<style>
    .wrapper>div:nth-last-of-type(5){
        background:orange;
    }
</style>
</head> 
<body>
<div class="wrapper">
  <p>我是第一个段落</p>
  <p>我是第二个段落</p>
  <div>我是第一个Div元素</div>
  <div>我是第二个Div元素</div>
  <div>我是第三个Div元素</div>
  <p>我是第三个段落</p>
  <p>我是第四个段落</p>
  <p>我是第五个段落</p>
  <div>我是第四个Div元素</div>
  <div>我是第五个Div元素</div>
  <p>我是第六个段落</p>
</div>
</body>
</html>

效果图如下

朗读
赞(0)
版权属于:

Dcr163的博客

本文链接:

https://www.dcr163.cn/129.html(转载时请注明本文出处及文章链接)

评论 (0)

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. https://www.triptipedia.com/user/phmapaladnet
    2025-05-08
  2. https://Sites.google.com/view/vavada-online-casino
    2025-04-12
  3. https://x.com/jeetbuzzcom
    2025-04-07
  4. prozone.cc alternative
    2025-03-19
  5. urgent delivery
    2025-03-16

标签云