css常见的布局

上中下 - 栏式

  .wap{
                width: 900px;
                margin: 0 auto;
            }
            #header{
                height: 100px;
                background: blanchedalmond;
            }
            #section{
                height: 700px;
                background: blue;
            }
            #footer{
                height: 100px;
                background: greenyellow;
            }
 <body>
        <header id='header' class='wap'></header>
        <section id='section' class="wap"></section>
        <footer id='footer' class="wap"></footer>
    </body>

左右两栏式(浮动+默认/浮动/定位父级相对子级绝对)

左右两栏加页眉页脚

  
  <header id='header' ></header>
        <section id='main'>
            <aside id='left'></aside>
            <div id='right'></div>
        </section>
        <footer id='footer'></footer>

左中右三栏(浮动的时候中间的是块级会单独占一行所以放到下面)

   .wrap{
                margin: 0 auto;
                width: 80%;
            }
            #left{
                width: 100px;
                height: 500px;
                background: lawngreen;
               float: left;
            }
            #main{
                height: 500px;
                background: royalblue;
                margin: 0 210px;
            }
            #right{
                width: 100px;
                height: 500px;
                background: black;
                float: right;
            }
 <div class="wrap">
            <aside id='left'></aside>
            <section id="right"></section>
            <aside id='main'></aside>
        </div>

左中右三栏之双飞翼

<style>
            .warp{
                margin: 0 auto;
                width: 100%;
            }
            #header{
                height: 100px;
                background: blue;
            }
            #main{
                height: 500px;
                background: blueviolet;
            }
            #footer{
                height: 100px;
                background: brown;
            }
            #middle{
                width: 100%;
                float: left;
            }
            #left{
                width: 200px;
                height: 100%;
                background: black;
                float: left;
                margin-left: -100%;
            }
            #right{
                width: 200px;
                height: 100%;
                background: black;
                float: right;
                margin-right: -100px;
                /* margin-left: -200%; */
            }
            .content{
                height: 500px;
                margin: 0 200px;
            }
        </style>
<body>
        <header id='header' class='warp'>header</header>
        <section id='main' class='warp'>
            <section id='middle'>
                <div class="content">content</div>
            </section>
            <aside id='left'>left</aside>
            <aside id='right'>right</aside>
        </section>
        <footer id='footer' class='warp'>footer</footer>
    </body>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值