webveuje/csspress/demo2/flex2.html

103 lines
2.0 KiB
HTML
Raw Normal View History

2021-01-20 18:33:56 +08:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding:0;
}
.box{
display:flex
}
.one{
height: 200px;
border: 1px solid red;
flex:1;
}
.two{
height: 200px;
border: 1px solid blue;
flex:1;
}
.box1{
width: 800px;
height: 400px;
background: skyblue;
display: flex;
justify-content: space-between;
margin-bottom: 20px;
}
.left{
width:20%;
height: 200px;
background: pink;
}
.right{
width:70%;
height: 200px;
background: silver;
}
.left1{
width:200px;
height: 200px;
background: pink;
}
.right1{
width:200px;
height: 200px;
background: silver;
}
.box2{
justify-content: center;
align-items: center;
}
html,
body {
height: 100%
}
.main {
display: flex;
height: 100%;
justify-content: center;
align-items: center;
border: 1px solid gray;
}
.box4 {
width: 300px;
border: 1px solid red;
}
</style>
</head>
<body>
<div class="box">
<div class="one"></div>
<div class="two"></div>
<div></div>
</div>
<div class="box1">
<div class="left"></div>
<div class="right"></div>
</div>
<div class="box1 box2">
<div class="left1"></div>
<div class="right1"></div>
</div>
<div class="main">
<div class="box4">未知高度上下左右居中</div>
</div>
</body>
</html>