实现两栏布局的几种方式
<!-- 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-12-19 01:27
华中师范大学 前端工程师 兑生:一开始只是想找个实习,找到实习了想进大厂,进大厂了想转正,转正了想offer打牌,打牌了想要大包,大包了想要wlb……
点赞 评论 收藏
分享
查看13道真题和解析 点赞 评论 收藏
分享
凡岛公司福利 520人发布