01-层叠性
<!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>CSS层叠性</title>
<style>
div {
color: brown;
font-size: 30px;
}
div {
color: pink;
}
</style>
</head>
<body>
<div>长江前浪推后浪,前浪死在沙滩上</div>
</body>
</html>
效果展示
![在这里插入图片描述](https://img-blog.csdnimg.cn/140973d1309f4083be19321accb5dc0c.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAV2FuZ1poYW5nXzUyMQ==,size_15,color_FFFFFF,t_70,g_se,x_16#pic_center)
02-继承性
<!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>CSS继承性</title>
<style>
div {
color: purple;
font-size: 20px;
}
</style>
</head>
<body>
<div>
<p>龙生龙,凤生凤,老鼠的孩子会打洞</p>
</div>
</body>
</html>
效果展示
![在这里插入图片描述](https://img-blog.csdnimg.cn/682da6a58c464eaea36521319167e052.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAV2FuZ1poYW5nXzUyMQ==,size_13,color_FFFFFF,t_70,g_se,x_16#pic_center)
02-继承性之行高的继承性
<!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>行高的继承</title>
<style>
body {
color: red;
font: 20px/1.5 'Microsoft YaHei';
}
div {
font-size: 14px;
}
p {
font-size: 16px;
}
</style>
</head>
<body>
<div>粉红色的回忆</div>
<p>粉红色的回忆</p>
<ul>
<li>我没有指定文字大小</li>
</ul>
</body>
</html>
效果展示
![在这里插入图片描述](https://img-blog.csdnimg.cn/d3c86f47f29f40c288328e44ba5ed2b2.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAV2FuZ1poYW5nXzUyMQ==,size_9,color_FFFFFF,t_70,g_se,x_16#pic_center)
03-优先级(哪个优先级高,则优先执行哪个)
<!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>CSS优先级</title>
<style>
div {
color: red !important;
}
.text {
color: royalblue;
}
#demo {
color: seagreen;
}
</style>
</head>
<body>
<div class="text" id="demo" style="color: violet;">你笑起来真好看</div>
</body>
</html>
04-CSS权重注意点
<!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>CSS权重注意点</title>
<style>
#father {
color: darkred;
}
p {
color: darkturquoise;
}
body {
color: fuchsia;
}
a {
color: pink;
}
</style>
</head>
<body>
<div id="father">
<p>你还是很好看</p>
</div>
<a href="#">我是单独的样式</a>
</body>
</html>
效果展示
![在这里插入图片描述](https://img-blog.csdnimg.cn/8f1b04d4f39e4d4299aec5702a2ab3c8.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAV2FuZ1poYW5nXzUyMQ==,size_8,color_FFFFFF,t_70,g_se,x_16#pic_center)