首页 > 其他 > 详细

两栏布局和三栏布局的实现

时间:2021-01-20 23:21:48      阅读:45      评论:0      收藏:0      [点我收藏+]

两栏布局

左侧固定,右侧自适应,不给右侧设置固定宽度即可

1.使用浮动float

1     <div class="wrap">
2         <div class="left">
3             左侧固定内容
4         </div>
5         <div class="right">
6             右侧内容自适应
7         </div>
8     </div>
 1     * {
 2         margin: 0;
 3         padding: 0;
 4     }
 5 
 6     .wrap {
 7         overflow: hidden;
 8         border: 1px solid red;
 9     }
10 
11     .left {
12         float: left;
13         width: 200px;
14         height: 200px;
15         background: aqua;
16     }
17 
18     .right {
19         margin-left: 200px;
20         background: aquamarine;
21         height: 200px;
22     }

技术分享图片技术分享图片

2.使用绝对定位absolute

1     <div class="wrap">
2         <div class="left">
3             左侧固定内容
4         </div>
5         <div class="right">
6             右侧内容自适应
7         </div>
8     </div>
 1     * {
 2         margin: 0;
 3         padding: 0;
 4     }
 5 
 6     .wrap {
 7         overflow: hidden;
 8         position: relative;
 9     }
10 
11     .left {
12         position: absolute;
13         left: 0;
14         top: 0;
15         width: 200px;
16         height: 200px;
17         background: aqua;
18     }
19 
20     .right {
21         margin-left: 200px;
22         background: aquamarine;
23         height: 220px;
24     }

技术分享图片技术分享图片

3.使用弹性布局flex

1     <div class="wrap">
2         <div class="left">
3             左侧固定内容
4         </div>
5         <div class="right">
6             右侧内容自适应
7         </div>
8     </div>
 1     * {
 2         margin: 0;
 3         padding: 0;
 4     }
 5 
 6     .wrap {
 7         display: flex;
 8     }
 9 
10     .left {
11         width: 200px;
12         height: 200px;
13         background: aqua;
14     }
15 
16     .right {
17         background: aquamarine;
18         height: 200px;
19         flex: 1;
20     }

技术分享图片技术分享图片

4.使用表格布局table 

1     <div class="wrap">
2         <div class="left">
3             左侧固定内容
4         </div>
5         <div class="right">
6             右侧内容自适应
7         </div>
8     </div>
 1     * {
 2         margin: 0;
 3         padding: 0;
 4     }
 5 
 6     .wrap {
 7         display: table;
 8         width: 100%;
 9     }
10 
11     .left {
12         display: table-cell;
13         width: 200px;
14         height: 200px;
15         background: aqua;
16     }
17 
18     .right {
19         display: table-cell;
20         background: aquamarine;
21         height: 200px;
22     }

技术分享图片技术分享图片

 

 

三栏布局

 

两栏布局和三栏布局的实现

原文:https://www.cnblogs.com/memeflyfly/p/14305107.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!