1.固定两栏布局,使用float,注意对紧邻元素清除浮动影响。IE6在使用float布局同时设置横行margin的情况下会有双边距BUG,解决方案是加入_display:inline

CSS布局——横向两列布局

 代码如下:

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>横向两列布局</title>
    <style type="text/css" >
        body{
            padding:0;
            margin:0;
        }
        .wrapper{
            width: 960px;
            margin:0 auto;
        }
        .header {
            height: 75px;
            background-color: #BD9C8C;
            margin-bottom: 5px;
        }
        .left{
            width: 340px;
            height: 600px;
            margin-right: 20px;
            _display:inline;/*IE6双边距BUG*/
            float: left;
            background-color:#E7DBD5;
        }
        .right{
            width: 600px;
            height: 600px;
            _display:inline;/*IE6双边距BUG*/
            float: left;
            background-color: #F2F2E6;
        }
        .footer {
            clear: both; /*清除浮动,非常重要,不可缺少*/
            background-color: #BD9C8C;
            margin-bottom: 5px;
        }
    </style>
</head>
<body>
<div class="wrapper">
    <div class="header">
        <h1>Header</h1>
    </div>
    <div class="left">
        <h2>left</h2>
    </div>
    <div class="right">
        <h2>right</h2>
    </div>
    <div class="footer">
        <h2>Footer</h2>
    </div>
</div>


</body>
</html>
View Code

相关文章: