这部分需要提前理解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>
* {
padding: 0;
margin: 0;
border: 0;
}
.main {
display: flex;
position: relative;
flex-direction: row;
justify-content: space-around;
align-items: center;
width: calc(100%);
height: 500px;
background-color: pink;
}
.main>div {
width: 100px;
height: 100px;
}
.main>div:nth-child(1) {
position: absolute;
top: 0;
left: 0;
background-color: red;
}
.main>div:nth-child(2) {
background-color: hotpink;
}
.main>div:nth-child(3) {
position: absolute;
bottom: 0;
right: 0;
background-color: green;
}
</style>
</head>
<body>
<div class="main">
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>
运行结果如下
新时代农民工冲冲冲!!!!!!!!