看下面的代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.red{
color: red;
}
</style>
</head>
<body>
<div class="red">我是div</div>
<p class="red">我是p</p>
</body>
</html>
如果我们想设置class为red的div的字体大小,如何写呢?
交集选择器
作用:选中同时复合多个条件的元素
语法:选择器1选择器2选择器3…选择器n{}
div.red{
font-size: 30px;
}
注意:元素选择器得写前面,不能写成red.div
并集选择器
如何让span和h1元素都变成紫色呢?并集选择器
作用:同时选中多个元素或id或class
语法:选择器1,选择器2{}
h1,span,.red,#r{
color: purple;
}