001_三栏布局(h3)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>三栏布局</title>
<style>
.wrapper {
margin-bottom: 20px;
}
.left, .middle, .right {
height: 400px;
}
.left, .right {
width: 200px;
background-color: red;
float: left;
}
.float .right {
float: right;
}
.float .middle {
background-color: blue;
margin: 0 200px;
}
.absolute {
position: relative;
height: 400px;
}
.absolute .left {
position: absolute;
left: 0;
background-color: red;
}
.absolute .middle {
position: absolute;
left: 200px;
right: 200px;
background-color: blue;
}
.absolute .right {
position: absolute;
right: 0;
background-color: red;
}
</style>
</head>
<body>
<h1>三栏布局</h1>
<div class="wrapper float">
<h2>浮动实现</h2>
<div class="left"></div>
<div class="right"></div>
<div class="middle"></div>
</div>
<div class="wrapper absolute">
<h2>定位实现实现</h2>
<div class="left"></div>
<div class="right"></div>
<div class="middle"></div>
</div>
</body>
</html>

002_水平垂直居中(h3)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>水平垂直居中</title>
<style>
.box {
width: 200px;
height: 200px;
background-color: red;
margin-bottom: 20px;
}
.box1 {
text-align: center;
line-height: 200px;
}
.box1 span {
background-color: blue;
}
.inner-box {
width: 50px;
height: 50px;
background-color: blue;
position: absolute;
top: 50%;
margin-top: -25px;
left: 50%;
margin-left: -25px;
}
.box2 {
position: relative;
}
.inner-box2 {
background-color: blue;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.box3 {
position: relative;
}
</style>
</head>
<body>
<h1>水平垂直居中</h1>
<div class="box box1">
<span>行内元素</span>
</div>
<div class="box box2">
<div class="inner-box">块级元素</div>
</div>
<div class="box box3">
<div class="inner-box2">块级元素</div>
</div>
</body>
</html>

003_BFC块级格式化上下文(h3)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BFC块级格式化上下文</title>
<style>
.box {
background-color: red;
border: 1px solid #000;
width: 600px;
overflow: hidden;
}
.float-box {
float: left;
height: 100px;
width: 100px;
border: 1px solid #000;
}
p {
width: 600px;
background-color: blue;
}
.first {
margin-bottom: 30px;
}
.second {
margin-top: 20px;
}
.margin-box {
overflow: hidden;
}
</style>
</head>
<body>
<div class="box">
<div class="float-box">it is float-box</div>
<div class="normal-box">it is normal-box</div>
</div>
<div>
<div class="margin-box">
<p class="first">123</p>
</div>
<p class="second">456</p>
</div>
</body>
</html>
