标签:right 三栏 前端 300px width 宽度 background display left
- 方式一:浮动
- 方式二:定位
- 方式三:flex
- 方式四:表格布局
- 方式五:grid网格布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>三栏布局几种实现方式</title>
<style>
*{
padding: 0;
margin: 0;
}
section,section div {
height: 100px;
}
</style>
</head>
<body>
<section class="way1">
<style>
.way1 .left {
float: left;
width: 300px;
background: red;
}
.way1 .right {
float: right;
width: 300px;
background: deepskyblue;
}
.way1 .center {
background: yellow;
margin: 0 300px;
}
</style>
<div class="left"></div>
<div class="right"></div>
<div class="center">浮动解决方案</div>
</section>
<section class="way2">
<style>
.way2 {
margin-top: 10px;
position: relative;
}
.way2 .left {
position: absolute;
left: 0;
width: 300px;
background: red;
}
.way2 .right {
position: absolute;
right: 0;
width: 300px;
background: deepskyblue;
}
.way2 .center {
position: absolute;
left: 300px;
right: 300px;
background: yellow;
}
</style>
<div class="left"></div>
<div class="right"></div>
<div class="center">定位解决方案</div>
</section>
<section class="way3">
<style>
.way3 {
margin-top: 10px;
display: flex;
}
.way3 .left {
width: 300px;
background: red;
}
.way3 .center {
flex: 1;
background: yellow;
}
.way3 .right {
width: 300px;
background: deepskyblue;
}
</style>
<div class="left"></div>
<div class="center">flex解决方案</div>
<div class="right"></div>
</section>
<section class="way4">
<style>
.way4 {
margin-top: 10px;
width: 100%;
display: table;
}
.way4 .left {
width: 300px;
display:table-cell;
background: red;
}
.way4 .right {
width: 300px;
display:table-cell;
background: deepskyblue;
}
.way4 .center {
display:table-cell;
background: yellow;
}
</style>
<div class="left"></div>
<div class="center">表格布局解决方案</div>
<div class="right"></div>
</section>
<section class="way5">
<style>
.way5{
margin-top: 10px;
width: 100%;
display: grid;
grid-template-rows: 100px;
grid-template-columns: 300px auto 300px;
}
.way5 .left {
background: red;
}
.way5 .right {
background: deepskyblue;
}
.way5 .center {
background: yellow;
}
</style>
<div class="left"></div>
<div class="center">网格布局解决方案</div>
<div class="right"></div>
</section>
</body>
</html>
标签:right,三栏,前端,300px,width,宽度,background,display,left 来源: https://blog.csdn.net/A798443266/article/details/100564512
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。