选择器进阶:
1.复合选择器
2.并集选择器
3.交集选择器
4.hover伪类选择器
复合选择器:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
/* 父选择器 儿子选择器*/
div p{
color: red;
}
</style>
</head>
<body>
<p>这是一个p标签</p>
<div>
<p>这是div儿子p</p>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div>a{
color: red;
}
</style>
</head>
<body>
<div>
父级
<a href="#">这是div里边的a</a>
<p>
<a href="#">这是div里边的p里边的a</a>
</p>
</div>
</body>
</html>
并集选择器:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p,div,span,h1{
color: red;
}
</style>
</head>
<body>
<p>ppppp</p>
<div>divdiv</div>
<span>spanspanspan</span>
<h1>h1h1h1</h1>
</body>
</html>
交集选择器:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p.box{
color: blue;
}
</style>
</head>
<body>
<p class="box">这是p标签:box</p>
<p>ppppppp</p>
<div class="box">这是div标签:box</div>
</body>
</html>
hover伪类选择器:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
a:hover{
color: red;
background-color: green;
}
</style>
</head>
<body>
<a href="#">这是超链接</a>
</body>
</html>
元素显示模式:
1.块级标签:
div p h系列 ul li dl dt dd form header nav footer
2.行内元素:
a span b u i s strong ins em del
3.行内块:
input textarea button select img
CSS特性:
1.层叠性
层叠性是对于属性而言的,同一个属性覆盖原来的属性2.继承性
继承性就是子承父业,当然儿子也可以继承祖业,父亲有的属性,儿子也有。文字属性都能继承。