Blogger Information
Blog 30
fans 0
comment 0
visits 23467
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
CSS布局之双飞翼
深海巨兽皮皮虾的博客
Original
789 people have browsed it

CSS经典布局双飞翼

核心:两侧固定宽度,中间宽度自适应

实现步骤:

1.创建DOM架构 

2.确定主体部分固定最小高度,两侧高宽 

3.全体浮动 

4.全体浮动

5.通过margin-left 移动两侧到指定为主 

6设置主体margin将中键内容挤出来

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>经典布局之双飞翼</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }

        .header,.footer{
            width: 100%;
            min-height: 60px;
            background-color: #888888;
            clear: both;
        }

        .box{
            margin: 0 auto;
            width: 1000px;
            height: 600px;

        }
        .container{
            width: 100%;
            background-color: skyblue;
            min-height: 600px;
            float: left;
        }
        .main{
            min-height: 600px;
            /*background-color: lightyellow;*/
            margin:0 200px;
        }

        .left{
            width: 200px;
            height: 600px;
            background-color: lightcoral;
            float: left;
            margin-left: -100%;

        }

        .right{
            width: 200px;
            height: 600px;
            background-color: lightgreen;
            float: left;
            margin-left: -200px;
        }
    </style>
</head>
<body>
<!--双飞翼布局-->
<div class="header">头部</div>
<div class="box">
    <div class="container">
        <div class="main">中间</div>
    </div>
    <div class="left">左侧</div>
    <div class="right">右侧</div>
</div>
<div class="footer">尾部</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例



Correction status:qualified

Teacher's comments:双飞翼的本质就是: float + margin, 记住这个就不会忘了
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post