三栏式布局,两边固定,中间自适应

本文介绍了一种使用HTML和CSS实现的三栏布局方案,该方案包括一个居中主要内容区域及两侧的固定宽度边栏,通过相对定位和浮动等技术确保了布局的稳定性。
 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 6     <meta http-equiv="X-UA-Compatible" content="ie=edge">
 7     <title>Document</title>
 8     <style>
 9         body, h1{padding: 0;margin: 0;}
10         header{width: 100%;height: 100px;background-color: green;}
11         footer{width: 100%; height: 100px;background-color: darkslategray;}
12         .left,.right,.center{float: left; height: 500px;}
13         .left,.right{ position: relative; width: 200px;}
14         .container{
15             overflow: hidden;
16             padding: 0 200px;
17         }
18         .center{
19             background-color: greenyellow;
20             width: 100%;
21         }
22         .right{
23             background-color: #3a9;
24             right: -200px;
25             margin-left: -200px;
26         }
27         .left{
28             background-color: #f00;
29             left: -200px;
30             margin-left: -100%;
31         }
32     </style>
33 </head>
34 <body>
35     <header><h1>header</h1></header>
36     <div class="container">
37         <div class="center">center</div>
38         <div class="left">left</div>
39         <div class="right">right</div>
40     </div>
41     <footer><h1>footer</h1></footer>
42 </body> 
43 </html>

 

转载于:https://www.cnblogs.com/gaoxuerong123/p/9501756.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值