CSS-三栏布局新手上路

在这之前你需要掌握的:

aside标签代表左右导航栏,article代表中间正文区域.hearder和footer代表上下栏.

margin: 0 0 0 0; 分别距离上下左右内容多少.

使用%描述页面长宽时,布局会随着页面的改变改变.

使用绝对值px,会导致在不同设备上,展示的网页会有所差异.

三栏布局例:

<body>
    <header>
        <h3>头部区域</h3>
    </header>
    <div>
        <aside class="left"><!-- 则边栏 -->
            <h3>左边导航栏</h3>
        </aside>
        <article class="middle">
            <h3>中间正文区域</h3>
        </article>
        <aside class="right">
            <h3>右侧导航栏</h3>
        </aside>
    </div>
    <footer>
        <h3>底部区域</h3>
    </footer>
</body>
*{
    padding: 0;
    margin: 0;
}

header,footer{
    height: 40px;
    width: 100%;/* 分成100份 */
    background: #ccc;
    text-align: center;
}

div{
    height: 800px;
    border: 1px double darkblue;
}

.left,.right{
    position: absolute;
    height:800px;  /*??px是绝对大小,改变窗口会产生影响*/
    top: 40px;
    background: #ff69b4;
}

.left{
    width: 20%;
    left: 0;
}
.right{
    width: 20%;
    right: 0;
}
.middle{
    height:800px; 
    width: 60%;
    margin: 0 0 20% 20%;
    background: #659;
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值