Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:完成的不错,继续加油
id
class
tag
id#权重最高 1.0.0
class.是主流 0.1.0
tag标签用来增加权重 0.0.1
<h2 class="title" id="header">hello</h2>
tag
标签
h2 {
color:red;
}
h2 {
color:red;
}
tag
标签 权重高低决定顺序
body h2 {
color:red;
}
class
权重高低决定顺序
.title {
color:red;
}
id
1.0.0 权重高低决定顺序
#header {
color:red;
}
width
height
padding
loorder
margin
可设置width
style
color
可设置width
大多数内置元素都有默认的padding
margin
<body>
<div class="box">hello</div>
<style>
body {
outline: 1px solid black;
}
.box {
width: 200px;
height: 100px;
border: 1px solid black;
padding:5px;
background-color: blueviolet;
background-clip: content-box;
}
</style>
</body>
212*112
源码大小200*100
标准计算:200px+10px+2px=212
*100px+10px+2px=112px
<div style="font-size: 1.25em;">
<div style="font-size: 2em">hello</div>
</div>
<body>
<div style="font-size: 1.25rem;">
<div style="font-size: 2rem">hello</div>
</div>
</body>
</html>
<style>
html {
font-size: 1rem;
}
</style>
<body>
<header>header</header>
<main>main</main>
<footer>footer</footer>
</body>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body > * {
outline:1px solid;
background-color:antiquewhite
}
header,
footer {
width: 100vw;
height: 5vh;
background-color:yellow;
}
main {
width: 100vw;
min-height:100vh;
margin: 0.5vh 0;
min-height: calc(100vh - 11vh);
}
</style>