Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
flex容器与项目的认识
<!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>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
font-size: 10px;
}
body {
font-size: 1.6rem;
}
.container {
border: 1px solid darkorange;
height: 40rem;
display: flex;
}
.container > .top {
border: 1px solid darkorange;
height: 20rem;
}
</style>
</head>
<body>
<div class="container">
<div class="top">我是第1</div>
<div class="top">我是第2</div>
<div class="top">我是第3</div>
<div class="top">我是第4</div>
</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>flex布局</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
font-size: 10px;
}
body {
font-size: 1.6rem;
}
.container {
border: 1px solid darkorange;
height: 40rem;
display: flex;
justify-content: space-evenly;
align-items: center;
}
.container > .top {
border: 1px solid darkorange;
height: 20rem;
width: 10rem;
}
.container > .top:nth-of-type(2) {
flex: none;
align-self: flex-start;
}
.container > .top:nth-of-type(3) {
flex: 1;
}
.container > .top:first-of-type {
order: 1;
background: aquamarine;
}
.container > .top:nth-of-type(4) {
align-self: flex-end;
}
</style>
</head>
<body>
<div class="container">
<div class="top">我是第1</div>
<div class="top">我是第2</div>
<div class="top">我是第3</div>
<div class="top">我是第4</div>
</div>
</body>
</html>