优先级
id>class>元素
可以通过(id,类,标签)个数进行比较
模块化和组件使用
header {
min-height: 20em;
background: lightskyblue;
color: red;
}
main {
min-height: 50em;
background: red;
color: black;
font-size: 20px;
font-style: inherit;
}
h1 {
color: cyan;
}
footer {
min-height: 10em;
background: purple;
color: skyblue;
}
<!DOCTYPE html>
<html lang="zh-CN">
<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>CSS2.0</title>
<style>
@import url(css/demo2.css);
</style>
</head>
<body>
<header>
<a href="">首页</a><a href="">第二页</a><a href="">第三页</a>末页<a
href=""
></a>
</header>
<main>
<h1>数字4.0解决方案</h1>
<p>方案</p>
</main>
<footer>
<p>仅限中国使用</p>
</footer>
</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>选择器</title>
<style>
ul li {
background: cyan;
}
/* body > ul > li {
background: red;
} */
/* .start + li {
background: white;
}
.start ~ li {
background: yellow;
} */
*/ tr:nth-of-type(2) {
background: green;
}
.list td:nth-of-type(3) {
background: cyan;
}
.list tr:nth-of-type(3) {
background: red;
}
#morder.list li:nth-last-of-type(1) {
background: greenyellow;
}
.start > li:nth-last-of-type(1) {
background: cadetblue;
}
.start > li:first-of-type {
background: purple;
}
</style>
</head>
<body>
<ul class="start" id="morder">
<li>item1</li>
<li>item2</li>
<li>
item3
<ul>
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ul>
</li>
<li>item4</li>
<li>item5</li>
</ul>
<div>
<table class="list" border="1" width="75%" cellspacing="0">
<tr>
<td>一</td>
<td>二</td>
<td>三</td>
</tr>
<tr>
<td>四</td>
<td>五</td>
<td>六</td>
</tr>
<tr>
<td>七</td>
<td>八</td>
<td>九</td>
</tr>
</table>
</div>
</body>
</html>