zoukankan      html  css  js  c++  java
  • 1-2:CSS3课程入门之结构选择

    E:nth-child(n)  表示E父元素中的第n个字节点
    p:nth-child(odd){background:red}/*匹配奇数行*/
    p:nth-child(even){background:red}/*匹配偶数行*/
    p:nth-child(2n){background:red}
    E:nth-last-child(n) 表示E父元素中的第n个字节点,从后向前计算
    E:nth-of-type(n)  表示E父元素中的第n个字节点,且类型为E
    E:nth-last-of-type(n)表示E父元素中的第n个字节点,且类型为E,从后向前计算 【先理解nth-of-type(n)
    E:empty 表示E元素中没有子节点。注意:子节点包含文本节点 ,例如<p></p>不能存在空格
    E:first-child 表示E元素中的第一个子节点
    E:last-child 表示E元素中的最后一个子节点
    E:first-of-type 表示E父元素中的第一个子节点且节点类型是E的
    E:last-of-type 表示E父元素中的最后一个子节点且节点类型是E的
    E:only-child表示E元素的父元素只有一个子节点。注意:子节点不包含文本节点,【<div><b></b></div> b:only-child
    E:only-of-type 表示E的父元素中只有一个子节点,且这个唯一的子节点的类型必须是E。注意:子节点不包含文本节点【
    <p><span>123</span><a href="">456</a></p>
    p *:only-of-type
    /*父级下某类型的标签仅有一个时该唯一元素会被选中*/

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>last-of-type与last-child区别</title>
        <style>
            *{margin:0; padding:0;}
            body *:last-of-type{
                height:30px;
                line-height:30px;
                border:1px solid red;
                background:yellow;
                margin-bottom:5px;
            }
           
        </style>
        </head>
    <body>
       <p>001</p>
       <h5>111</h5>
       <p>002</p>
       <p>003</p>
       <h5>222</h5>
       <p>004</p>
       <p>005</p>
    </body>
    </html>
  • 相关阅读:
    【浅谈数位计数一类问题】
    2.2、idea 中写spark sql
    javascript事件之鼠标滚轮(mousewheel)和DOMMouseScroll事件
    JS 判断鼠标滚轮的上下滚动
    gulp 用法 小结
    'gulp'不是内部或者外部命令,也不是可运行的程序
    Gulp的安装与配置
    前端构建工具gulpjs的使用介绍及技巧
    【转】弧度和角度的转换
    前端构建工具gulpjs的使用介绍及技巧
  • 原文地址:https://www.cnblogs.com/jewave/p/7580672.html
Copyright © 2011-2022 走看看