Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:这几个单位, 是布局的基础
代码小案例:
<style>
:root{
/* 定义了一个根元素值 */
font-size: 1em;
}
.px{
font-size: 16px;
width: 200px;
height: 200px;
border: 1px solid red;
}
.em{
/* 字号被修改,新的值成为父级新值 */
font-size: 1.25em;
width: 15em;
height: 15em;
border: 1px solid blue;
}
.rem{
/* 字号取决于根元素的值 */
font-size: 1rem;
width: 20rem;
height: 20rem;
border: 1px solid springgreen;
}
</style>
</head>
<body>
<div class="container">
<div class="px">px绝对尺寸</div>
<div class="em">em相对尺寸</div>
<div class="rem">rem相对尺寸</div>
</div>
实例图
总结:
代码部分
<style>
* {
margin: 0;
padding: 0;
}
.header {
width: 100vw;
height: 10vh;
background-color: cornflowerblue;
line-height:10vh;
text-align:center;
position: relative;
font-size: 2rem;
justify-content: center;
display: flex;
}
.main {
float: left;
width: 100vw;
height: 70vh;
background: rgb(36, 221, 19);
line-height:70vh;
text-align:center;
font-size: 2rem;
justify-content: center;
display: flex;
}
.footer {
float: left;
width: 100vw;
height: 20vh;
background: rgb(221, 19, 194);
line-height:20vh;
text-align:center;
font-size: 2rem;
justify-content: center;
display: flex;
}
</style>
效果演示