方法一:浮动
<!DOCTYPE html>
<html>
<head>
<style>
.left{
float:left;
width:200px;
height: 400px;
background: blue;
}
.right{
float: right;
width: 200px;
height: 400px;
background: red;;
}
.center{
height: 400px;
background: yellow;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="left">
左边
</div>
<div class="right">
右边
</div>
<div class="center">
中间
</div>
</div>
</body>
</html>
方法二:flex
<!DOCTYPE html>
<html>
<head>
<style>
.wrapper{
display: flex;
}
.left,.right{
height: 400px;
width: 200px;
}
.left{
background: blue;
}
.right{
background: red;
}
.center{
flex:1;
height: 400px;
background: yellow;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="left">
左边
</div>
<div class="center">
中间
</div>
<div class="right">
右边
</div>
</div>
</body>
</html>
方法三:绝对布局
<!DOCTYPE html>
<html>
<head>
<style>
.wrapper{
position: relative;
}
.left,.right,.center{
position: absolute;
height: 400px;
}
.left{
left:0;
background: blue;
width: 200px;
}
.right{
right: 0;
background: red;
width: 200px;
}
.center{
left: 200px;
right: 200px;
background: yellow;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="left">
左边
</div>
<div class="center">
中间
</div>
<div class="right">
右边
</div>
</div>
</body>
</html>
方法四:table布局
<!DOCTYPE html>
<html>
<head>
<style>
.wrapper{
display: table;
width: 100%;
}
.left,.right,.center{
display: table-cell;
height: 400px;
}
.left{
background: blue;
width: 200px;
}
.right{
background: red;
width: 200px;
}
.center{
background: yellow;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="left">
左边
</div>
<div class="center">
中间
</div>
<div class="right">
右边
</div>
</div>
</body>
</html>
方法五:grid布局
<!DOCTYPE html>
<html>
<head>
<style>
.wrapper{
display: grid;
width: 100%;
grid-template-rows: 400px;
grid-template-columns: 200px auto 200px;
}
.left{
background: blue;
}
.right{
background: red;
}
.center{
background: yellow;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="left">
左边
</div>
<div class="center">
中间
</div>
<div class="right">
右边
</div>
</div>
</body>
</html>
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。