zoukankan      html  css  js  c++  java
  • css结构伪类选择器

    first-child、last-child、nth-child(n)、nth-of-type(n).

    <style>
            /*选择属于其父元素的首个子元素的每个 <p> 元素,并为其设置样式*/
            p:first-child{
                background: yellow;
            }
            /*指定属于其父元素的最后一个子元素的 p 元素的背景色*/
            p:last-child{
                background: dodgerblue;
            }
            /*选择在父类元素中处于第一个或最后一个位置p元素*/
    </style>
    
    <style>
            /*规定属于其父元素的第n个子元素的每个 p 的背景色:*/
            p:nth-child(2){
                background: dodgerblue;
            }
            /*找到在父元素中中处于第n位的 p 元素*/
    </style>
    
    <style>
            /*规定属于其父元素的第二个 p 元素的每个 p:*/
            p:nth-of-type(2){
                background: red;
            }
            /*找到在某个子元素列表中的第 n个 p元素*/
    </style>
    
  • 相关阅读:
    8.3学习日志
    8.2学习日志
    8.1学习日志
    Chapter 2
    未命名 1
    pugixml
    C++使用Json作为数据包装格式的通信
    项目FAQ
    xcode语法高亮插件
    【转】jsoncpp在xcode中的使用
  • 原文地址:https://www.cnblogs.com/zhang-han/p/14174749.html
Copyright © 2011-2022 走看看