1、通过绝对定位(position:absolute),实现三列布局
实例
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <title>使用绝对定位(position:absolute)实现三列布局</title> <!-- <link rel="stylesheet" href="css/style3c.css">--> <style> .container{ width: 1000px; margin: 0 auto; } .main{ position: relative; background-color: lightblue; margin: 5px auto; } .content{ min-height: 600px; line-height: 600px; text-align: center; background-color: lightseagreen; margin-left: 210px; margin-right: 210px; } .header, .footer{ background-color: lightgrey; height: 60px; text-align: center; line-height: 60px; } .left, .right{ width: 200px; height: 600px; line-height: 600px; text-align: center; } .left{ background-color: lightgreen; position: absolute; top: 0; left: 0; } .right{ background-color: lightcoral; position: absolute; top: 0; right: 0; } </style> </head> <body> <div class="container"> <div class="header">头部.header</div> <div class="main"> <div class="left">左侧.left</div> <div class="content">内容区.content</div> <div class="right">右侧.right</div> </div> <div class="footer">底部.footer</div> </div> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
2、通过浮动float,实现三列布局
实例
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <title>通过浮动float,实现三列布局</title> <!-- <link rel="stylesheet" href="css/style4c.css">--> <style> .container { width: 1000px; margin: 0 auto; background-color: red; } .header, .footer { height: 60px; background-color: lightgrey; } .main { background-color: black; margin: 5px auto; overflow: hidden; } .left, .right { width: 200px; height: 600px; } .left { background-color: lightgreen; float: left; } .right { background-color: lightcoral; float: right; } .content{ float: left; width: 580px; min-height: 600px; margin-left: 10px; background-color: lightseagreen; } </style> </head> <body> <!-- 使用浮动布局: 1、先将main下的(.left, .content, .right)全部float 2、通过对他们的父容器main使用overflow:hidden清除浮动 --> <div class="container"> <div class="header">头部.footer</div> <div class="main"> <div class="left">左侧栏.left</div> <div class="content">内容区.content</div> <div class="right">右侧栏.right</div> </div> <div class="footer">底部.footer</div> </div> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
3. 完成双飞翼布局案例
待完成……