Correcting teacher:灭绝师太
Correction status:qualified
Teacher's comments:
<!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>
/* id优先级高于类 101*/
#php2 p {
color: blue;
}
/* 类优先级高于标签 011*/
.php p {
color: yellow;
}
p {
color: red;
}
/* 同级,后者覆盖前者 */
p {
color: green;
}
</style>
</head>
<body>
<div class="php" id="php2">
<p>我爱PHP</p>
</div>
</body>
</html>
<!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>
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<header></header>
<main></main>
<footer></footer>
</body>
</html>
####index.css文件
@import url(header.css);
@import url(main.css);
@import url(footer.css);
####header.css文件
header {
height: 50px;
background-color: yellow;
}
####main.css文件
main {
height: 400px;
background-color: blue;
}
####footer.css文件
footer {
height: 80px;
background-color: red;
}
<!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>
/* 伪类选择器使用方式 */
/* 选择第一个元素 */
.list > li:first-of-type {
background-color: red;
}
/* 选择最后一个元素 */
.list > li:last-of-type {
background-color: aqua;
}
/* 选择第三个元素 */
.list >li:nth-of-type(3) {
background-color: blue;
}
/* 选择倒数第二个元素 */
.list > li:nth-last-of-type(2) {
background-color: cornflowerblue;
}
</style>
</head>
<body>
<ul class="list">
<li>item1</li>
<li>item2</li>
<li>item3</li>
<li>item4</li>
<li>item5</li>
<li>item6</li>
</ul>
</body>
</html>