三栏布局:左右定宽,中间自适应。文章来源:https://www.toymoban.com/news/detail-650112.html
- 左右浮动,中间自适应
<!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 div {
height: 100vh;
}
.left {
width: 300px;
float: left;
background: rgb(202, 233, 91);
}
.right {
width: 300px;
float: right;
background: rgb(213, 125, 237);
}
.center {
background-color: rgb(96, 232, 175);
}
</style>
</head>
<body>
<div class="box">
<div class="left">left</div>
<div class="right">right</div>
<div class="center">center</div>
</div>
</body>
</html>
- 绝对定位
<!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 div {
height: 100vh;
}
.left {
width: 300px;
position: absolute;
left: 0;
background: rgb(239, 106, 106);
}
.right {
width: 300px;
position: absolute;
right: 0;
background: rgb(104, 229, 189);
}
.center {
position: absolute;
left: 300px;
right: 300px;
background-color: rgb(195, 240, 105);
}
</style>
</head>
<body>
<div class="box">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
</body>
</html>
文章来源地址https://www.toymoban.com/news/detail-650112.html
- flexbox布局
<!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 div {
height: 100vh;
}
.box {
display: flex;
}
.left {
width: 300px;
background: rgb(232, 110, 110);
}
.right {
width: 300px;
background: rgb(172, 223, 101);
}
.center {
flex: 1;
background-color: rgb(156, 103, 236);
}
</style>
</head>
<body>
<div class="box">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
</body>
</html>
到了这里,关于【CSS】CSS 布局——常规流布局的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!