zoukankan      html  css  js  c++  java
  • CSS3---first-child或者nth-child(1) 不起作用的原因

    一、零碎
         1、first-child、last-child、nth-child(n)、nth-child(2n)、nth-child(2n-1)、nth-child(odd)、nth-child(even)、nth-last-child(3)(倒数第三个)
              注意点: 选择器匹配属于其父元素的第 N 个子元素不论元素的类型
              1、先找到该伪类调用者(元素)的父类
              2、其次找到父类下的第n个子元素
              3、最后看该子元素是不是1中的伪类调用者,如果是,则应用css,否则不应用
              ----》有时候first-child或者nth-child(1) 不起作用的原因
     
    /*此时first-child不起作用,是因为.tap_con的父元素win的第一个子元素是.top,此时找到第一个子元素,但是其并不是.tab_con*/
       <div id="win">
            <div class="top">
            </div>
            <div class="tab_con">
            </div>
            <div class="tab_con">
            </div>
       </div>
     
    ==========================================================
    .tab_con:first-child{
        background:#090 !important;
    }
    ==========================================================
    .tab_con:nth-child(1){
        background:#090 !important;
    }
  • 相关阅读:
    AcWing每日一题--数字三角形
    AcWing每日一题--货仓选址
    Codeforces Round #693
    动态规划--多重背包
    动态规划--完全背包
    动态规划--01背包
    博弈论--SG函数
    博弈论--Nim游戏
    基础数论--容斥定理
    基础数论--卡特兰数
  • 原文地址:https://www.cnblogs.com/hihao/p/7389813.html
Copyright © 2011-2022 走看看