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;
    }
  • 相关阅读:
    meta标签
    html5新增标签
    jQuery鼠标事件
    Jenkins在Linux环境安装
    3、jQuery的DOM基础
    2、jQuery选择器
    1、jQuery概述
    伪分布模式安装hadoop
    poj 2773欧几里德
    poj 1298(水题)
  • 原文地址:https://www.cnblogs.com/hihao/p/7389813.html
Copyright © 2011-2022 走看看