前端css基础知识点之selector——选择器

前端css基础知识点之selector——选择器

7种常用选择器

1、通配符选择器 * 表示所有标签

* {
    
    
    background-color: blue;
} 

2、标签选择器 标签名 一般对一类标签设置样式 采用

h1 {
    
    
    color: red;
}
a {
    
    
    text-decoration: none;
}

3、id选择器 #id 用的不多 一般用在独一无二的元素

#box2 {
    
    
    background-color: green;
}

4、类选择器 .class 用的最多

.f30 {
    
    
    font-size: 30px;
}

5、并集选择器(群组选择器) p div h2 字颜色为红色

p,
h2,
div {
    
    
    color: red;
}

6、交集选择器 li.f30 既是li又class是f30

li.f30 {
    
    
    text-decoration: underline;
}

7、后代选择器

div .f30 {
    
    
    font-weight: 700;
}

猜你喜欢

转载自blog.csdn.net/Sun_Raiser/article/details/118711707