• nth-of-type和nth-child的区别


    ---恢复内容开始---

    nth-of-type这一类的选择器是针对同类型的子元素进行计算;

    nth-child这一类的先择器是连同父元素中的所有子元素一起计算;

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
           /*h2:nth-child(even){*/
               /*background: blue;*/
           /*}*/
          /*h2:nth-child(odd){*/
               /*background: aquamarine;*/
           /*}*/
            h2:nth-of-type(even){
                background: blue;
            }
           h2:nth-of-type(odd){
               background: yellowgreen;
           }
        </style>
    </head>
    <body>
    <div>
        <h2> 标题1</h2>
        <p>内容 ......三万字</p>
        <h2>标题2</h2>
        <p>内容 ......三万字</p>
        <h2>标题3</h2>
        <p>内容 ......三万字</p>
        <h2>标题4</h2>
        <p>内容 ......三万字</p>
        <h2>标题5</h2>
        <p>内容 ......三万字</p>
        <h2>标题6</h2>
        <p>内容 ......三万字</p>
    </div>
    </body>
    </html>

    标题1

    内容 ......三万字

    标题2

    内容 ......三万字

    标题3

    内容 ......三万字

    标题4

    内容 ......三万字

    标题5

    内容 ......三万字

    标题6

    内容 ......三万字

    还有相似的有选择器nth-last-child和nth-last-of-type;

                              

    “我相当乐意花一天的时间通过编程把一个任务实现自动化,除非这个任务手动只需要10秒钟就能完成”
  • 相关阅读:
    https原理以及golang基本实现
    关于Goroutine与Channel
    Golang中log与fmt区别
    liteide使用中的注意点
    Golang中的error类型
    关于linux中的目录配置标准以及文件基本信息
    Godep的基本使用
    Golang基本类型整理
    ssh使用技巧
    看完让你彻底搞懂Websocket原理
  • 原文地址:https://www.cnblogs.com/flxy-1028/p/6053670.html
Copyright © 2020-2023  润新知