CSS——选择器

1.标签选择器

<style type="text/css">
h1{
    font-weight:normal;   
    color:red;
}    
</style>

2.类选择器  .

<style type="text/css">
.stress{
    color:red;
}
</style>

3.id选择器 #

<style type="text/css">
#stress{
    color:red;
}
</style>

4.子选择器 >

<style type="text/css">
.food>li{border:1px solid red;}
.first>span{border:1px solid red;}
</style>

5.包含(后代选择器)  空格

<style type="text/css">
.first span{color:red;}
</style>

6.通用选择器  *

<style type="text/css">
* {color:red;
   font-size:20px;
    }
</style>

7.伪类选择符  :

<style type="text/css">
a:hover{
    color:red;
    font-size:20px;
}
</style> 

8.分组选择符(多个元素同时设置)  ,

<style type="text/css">
h1,span{color:red;}
.first,span{color:green;}
</style>  
原文地址:https://www.cnblogs.com/congyue-pepsi/p/5664798.html