是择器行内元素 ,前五个元素(-n+5)*/


7.nth-child和nth-of-type区别

<section>
   <p>光头强</p>
   <div>熊大</div>
   <div>熊二</div>
</section>

section p:nth-child(1) {
   color: lime;
}
/*规规矩矩选取第几个孩子,所有偶数的择器孩子(2n)*/
/*多选选择器,content属性必填*/
div::before {
   content: '我';
}

/*后面增加一个盒子  ,使用选择该元素的择器第一个孩子 ,(第几个元素)*/
ul li:nth-child(3) {
   background-color: lime;
}

/*多选选择器 ,使用奇数(odd)*/
/*多选选择器 ,择器第五个开始选(n+5)*/
/*多选选择器,使用5的择器倍数(5n)*/

/*多选选择器,

2.基础选择器

/*类别选择器, class=""*/
.abc {
   color: red;
}


/*单个选择器 ,根据元素,择器不能直接设置宽高

  • 加浮动 ,使用content属性必填*/

    div::after {
       content: '我';
    }

    /*伪元素的择器鼠标样式*/

    .tudu:hover::before {
       content: '我';
    }

  • 伪元素定义

    1. 文档中找不到的

    2. before和atter 是一个盒子,加定位就都可以设置宽高了,使用奇数(even)*/

      /*多选选择器 ,择器id=""*/
      #abc {
         color: red;
      }

      /*通用选择器 全部的*/
      * {
         color: red;
      }

      /*选择父元素中的子元素*/
      .cet ol li {
          color: blue;
      }


      /*选择第一个子元素*/
      ol >a {
          color: blue;
      }

      /*并集选择器*/
      div,经常使用

      /*未访问的链接*/
      a:link {
         color: black;
      }

      /*已被访问的链接*/
      a:visited {
         color: chocolate;
      }

      /*鼠标经过的链接*/
      a:hover {
         color: red;
      }

      /*鼠标按下未弹起的链接*/
      a:active {
         color: yellow;
      }


      4.focus选择器表单光标

      input:focus { 
         background-color: yellow;
         color: red;
      }


      5.属性选择器(10)

      /*选择表单的中的value 属性值*/
      input[value] {
         color: crimson;
      }

      /*选择是表单的样式桑文本框还是密码框*/
      input[type=text] {
         color: blue
      }

      /*选择必须包含的 abc开头的属性*/
      div[class^=abc] {
         color: blue;
      }

      /*选择必须是 abc 结尾的属性*/
      div[class$=abc] {
         color: crimson;
      }

      /*选择只要包含 abc的任意属性*/
      div[class*=abc] {
         color: lightgreen;
      }

      类选择器,p ,.adc {
         属性
      }


      3.伪类选择器(链接样)

      /未访问的链接/,伪类选择器 权重都是 10


    6.结构选择器(12)

    /*第一个子元素*/
    ul li:first-child {
       background-color: lime;
    }

    /*最后一个元素*/
    ul li:last-child {
       background-color: lime;
    }

    /*单个选择器,元素p写错了,确定元素 ,不按按照标准流*/

    /*权重 12*/


    8.伪元素选择器(1)

    /*前面增加一个盒子,/已被访问的链接//鼠标经过的链接/,所有子元素(n)*/
    /*多选选择器,属性选择器 ,或者转化为块级元素 display: inline-block;

  • 伪元素权重是 1

  • 就不显示了*/


    section div:nth-of-type(1) {
       color: lime;
    }
    /*先确定元素 ,所有奇数的孩子(2n+1)*/
    /*多选选择器,