CSS选择器

一、元素选择器:

    其权重值为:0001;

  表示为:div{color:red;}

二、类选择器:

      其权重值为:0010;

  表示为:.div1{color:red;}

      <div class="div1">

三、ID选择器:

    其权重值为:0100;

  表示为:#div1-id{color:red;}

      <div id="div1-id">

四、属性选择器:

    其权重值为:0010;

五、后代(包含)/(派生)选择器:

    其权重值为:0000;

  表示为:h1 span{color:red;}

      <h1>This is a <span>head</span>endding</h1>

      这里的head将显示为红色;

六、子元素选择器:

    其权重值为:0000;

  表示为:h1>strong{color:red;}

      <h1>This is a <strong>head <span>very</span>head</strong>endding</h1>

      这里的head将显示为红色,very不会显示为红色;

七、相邻兄弟选择器:

    其权重值为:0000;

  表示为:li+li;

   

原文地址:https://www.cnblogs.com/xingxing88/p/5937013.html