实现两栏布局的几种方式
<!-- HTML结构 -->
<div class="wrap">
<div class="left">
左侧固定内容
</div>
<div class="right">
右侧内容自适应
</div>
</div>
-----利用margin-left
1.使用浮动—float
2.使用绝对定位实现—absolute
3.使用calc()函数
4.使用inline-block和calc()函数
---使用弹性布局—flex
.wrap {
display: flex;
}
.left {
height: 200px;
background: purple;
flex:0 0 200px
}
.right {
background: skyblue;
height: 200px;
flex: 1;
}
----使用表格布局—table(不推荐使用)
.wrap {
display: table;
width: 100%;
}
.left {
display: table-cell;
width: 200px;
height: 200px;
background: purple;
}
.right {
display: table-cell;
background: skyblue;
height: 200px;
}
<!-- HTML结构 -->
<div class="wrap">
<div class="left">
左侧固定内容
</div>
<div class="right">
右侧内容自适应
</div>
</div>
-----利用margin-left
1.使用浮动—float
2.使用绝对定位实现—absolute
3.使用calc()函数
4.使用inline-block和calc()函数
---使用弹性布局—flex
.wrap {
display: flex;
}
.left {
height: 200px;
background: purple;
flex:0 0 200px
}
.right {
background: skyblue;
height: 200px;
flex: 1;
}
----使用表格布局—table(不推荐使用)
.wrap {
display: table;
width: 100%;
}
.left {
display: table-cell;
width: 200px;
height: 200px;
background: purple;
}
.right {
display: table-cell;
background: skyblue;
height: 200px;
}
全部评论
相关推荐
点赞 评论 收藏
分享
2025-11-07 10:05
石家庄市第一职业中专学校 后端工程师 StephenZ_:我9月份找的第一段实习也是遇到这种骗子公司了,问他后端有多少人和我说7个正职,进去一看只有一个后端剩下的都是产品前端算法(没错甚至还有算法)。还是某制造业中大厂,我离职的时候还阴阳怪气我
点赞 评论 收藏
分享