flex布局小demo
<style>
body {
display: flex;
/*flex-direction: column;*/
/*flex-wrap: wrap;*/
/*flex-wrap: wrap-reverse;*/
/*justify-content: flex-start;*/
/*justify-content: flex-end;*/
/*justify-content: center;*/
/*justify-content: space-between;*/
/*justify-content: space-around;*/
/*align-items: center;*/
/*align-items: flex-start;*/
/*align-items: flex-end;*/
/*align-items: baseline;*/
/*align-content: center;*/
/*align-content: space-between;*/
/*align-content: space-around;*/
/*align-content: stretch;*/
width: 80vw;
height: 80vh;
margin: 2rem auto;
border: 1px solid #000;
}
.box1 {
display: flex;
justify-content: center;
align-items: center;
/*order: 5;*/
flex-shrink: 0;
width:30%;
height:30%;
border: 1px solid #ff0000;
}
.box2 {
width:60%;
height: 60%;
background-color: #ffff00;
}
.box3 {
width: 30%;
height:30%;
background-color: #d58512;
}
.box4 {
width: 20%;
height: 30%;
background-color: #2aabd2;
}
.box5 {
/*align-self: flex-end;*/
/*flex-shrink: 0;*/
/*flex-grow: 1;*/
width: 10%;
height: 20%;
background-color: #32c086;
}
.box6 {
width: 50%;
height: 40%;
background-color: #5fc0cd;
}
</style>
完成代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>flex编码实战</title>
<style>
body {
display: flex;
/*flex-direction: column;*/
/*flex-wrap: wrap;*/
/*flex-wrap: wrap-reverse;*/
/*justify-content: flex-start;*/
/*justify-content: flex-end;*/
/*justify-content: center;*/
/*justify-content: space-between;*/
/*justify-content: space-around;*/
/*align-items: center;*/
/*align-items: flex-start;*/
/*align-items: flex-end;*/
/*align-items: baseline;*/
/*align-content: center;*/
/*align-content: space-between;*/
/*align-content: space-around;*/
/*align-content: stretch;*/
width: 80vw;
height: 80vh;
margin: 2rem auto;
border: 1px solid #000;
}
.box1 {
display: flex;
justify-content: center;
align-items: center;
/*order: 5;*/
flex-shrink: 0;
width:30%;
height:30%;
border: 1px solid #ff0000;
}
.box2 {
width:60%;
height: 60%;
background-color: #ffff00;
}
.box3 {
width: 30%;
height:30%;
background-color: #d58512;
}
.box4 {
width: 20%;
height: 30%;
background-color: #2aabd2;
}
.box5 {
/*align-self: flex-end;*/
/*flex-shrink: 0;*/
/*flex-grow: 1;*/
width: 10%;
height: 20%;
background-color: #32c086;
}
.box6 {
width: 50%;
height: 40%;
background-color: #5fc0cd;
}
</style>
</head>
<body>
<div class="box1">1
<div class="box2">2</div>
</div>
<div class="box3">3</div>
<div class="box4">4</div>
<div class="box5">5</div>
<div class="box6">6</div>
</body>
</html>