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>
效果展示
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>
效果展示
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>
效果展示
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>
效果展示