<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!--SEO优化-->
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>三栏布局</title>
<style media="screen">
html *{
margin: 0px;
padding: 0px;
}
.layout article div {
min-height: 100px;
}
section {
margin-top: 30px;
}
</style>
</head>
<body>
<section class="float layout">
<style media="screen">
.float.layout .left {
float: left;
width: 300px;
background: red;
}
.float.layout .right {
float: right;
width: 300px;
background: blue;
}
.float.layout .center {
background: orange;
}
</style>
<article class="right-left-center">
<div class="left"></div>
<div class="right"></div>
<div class="center">
<h2>float浮动布局</h2>
</div>
</article>
</section>
<section class="position layout">
<style>
.position.layout .left {
position: absolute;
left: 0;
width: 300px;
background-color: red;
}
.position.layout .right {
position: absolute;
right: 0;
width: 300px;
background-color: blue;
}
.position.layout .center {
position: absolute;
right: 300px;
left: 300px;
background-color: orange;
}
</style>
<article class="right-left-center">
<div class="left"></div>
<div class="right"></div>
<div class="center">
<h2>
position绝对定位
</h2>
</div>
</article>
</section>
<section class="flexbox layout">
<style>
.flexbox.layout {
margin-top: 160px;
}
.layout.flexbox .right-left-center {
display: flex;
}
.layout.flexbox .left {
width: 300px;
background-color: red;
}
.layout.flexbox .right {
width: 300px;
background-color: blue;
}
.layout.flexbox .center {
background-color: orange;
flex: 1;
}
</style>
<article class="right-left-center">
<div class="left"></div>
<div class="center">
<h2>flexbox flex布局</h1>
</div>
<div class="right"></div>
</article>
</section>
<section class="table-cell layout">
<style>
.table-cell.layout .right-left-center {
display: table;
height: 100px;
width: 100%;
}
.table-cell.layout .right-left-center>div {
display: table-cell;
}
.table-cell.layout .left {
width: 300px;
background: red;
}
.table-cell.layout .right {
width: 300px;
background: blue;
}
.table-cell.layout .center {
background: orange;
}
</style>
<article class="right-left-center">
<div class="left"></div>
<div class="center">
<h2>table 表格布局</h2>
</div>
<div class="right"></div>
</article>
</section>
<section class="layout grid">
<style>
.layout.grid .right-left-center {
display: grid;
width: 100%;
grid-template-rows: 100px;
grid-template-columns: 300px auto 300px;
}
.layout.grid .left {
background: red;
}
.layout.grid .center {
background: orange;
}
.layout.grid .right {
background: blue;
}
</style>
<article class="right-left-center">
<div class="left"></div>
<div class="center">
<h2>grid 网格布局</h2>
</div>
<div class="right"></div>
</article>
</section>
</body>
</html>
三栏布局的5种方法
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...