【Web】css盒子模型创建网页布局

盒子模型

CSS在描述HTML元素时,会形成一个矩形框,可以将矩形框形象的看成一个盒子。每个HTML元素,都具有盒子模型。

这里写图片描述

使用盒子模型创建网页布局

index.html + out.css

index.html

<html>
<head>
<link rel="stylesheet" href="out.css" />
</head>
<body>
<div id="container">
    <div id="header">Header
    <p>CSS盒子模型创建网页布局<p>
    </div>
    <div id="menu">Menu
    </div>
    <div id="maincontent">
        <div id="sidebar1">SideBar1</div>
        <div id="sidebar2">SideBar2</div>
        <div id="content">Content</div>
    </div>
</div>
<div id="footer">Footer</div>
</body>
</html>

out.css

body{
    font-family:Arial;
    font-size:24px;
    margin:0;
    padding:0;
}

p{
    font-size:18px;
}

#conainer{
    margin:auto;
    width:auto;
}

#header{
    height:150px;
    background:#7DC85F;
    margin-bottom:5px;
}

#menu{
    height:30px;
    background:#7DC85F;
    margin:5px;
}

#mainContent{
    height:400px;
    margin-bottom:5px;
}

#sidebar1{
    float:left;
    width:200px;
    height:100%;
    background:#7DC85F;
}

#sidebar2{
    float:right;
    width:200px;
    height:100%;
    background:#7DC85F;
}

#content{
    margin:0 205px;
    height:100%;
    background:#7DC85F;
}

#footer{
    height:60px;
    background:#7DC85F;
}

web效果

这里写图片描述

  • 9
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值