HTML布局----div布局&&table

HTML布局

1、<div>元素布局

我们一般最先想到的一个网页的结构是

头部+内容菜单+主体+底部

因此我们可以先定义

<span style="font-size:14px;"><body>
    <div id="container">
        <div id="heading">头部</div>
        <div id="content_menu">内容菜单</div>
        <div id="content_body">内容主体</div>
        <div id="footing">底部</div>
    </div>
</body></span>
看运行结果没有得到我们想要的布局,因为我们没有设置样式,离开样式的div没有什么意义

<span style="font-size:14px;"><!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>div布局</title>
    <style type="text/css">
        body{
            margin:0px;
        }
        #container{
            width:100%;
            height:950px;
            background-color:#999999;
        }
        #heading{
            width:100%;
            height:10%;
            background-color:#00FFFF;
        }
        #content_menu{
            width:30%;
            height:80%;
            background-color:#FFFF00;
            float:left;}
        #content_body{
            width:70%;
            height:80%;
            background-color:#FF3300;
            float:left;}
        #footing{
            width:100%;
            height:10%;
            background-color:#000000;
            clear:both;}
    </style>
</head>
<body>
    <div id="container">
        <div id="heading">
            <h1>这是头部</h1>
        </div>
        <div id="content_menu">内容菜单</div>
        <div id="content_body">内容主体</div>
        <div id="footing">底部</div>
    </div>
</body>
</html></span>
这样就可以得到我们想要的几个部分,至于中间的内容及具体样式,可再具体化代码。

2、<table>元素布局

布局也可以用<table>布局

<span style="font-size:14px;color:#333333;"><!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>table布局</title>
</head>

<body marginheight="0px" marginwidth="0px">
    <table width="100%" height="950px" style="background-color:#999999">
        <tr>
            <td colspan="2" width="100%" height="10%" style="background-color:#FF0000">这是头部</td>
        </tr>
        <tr>
            <td width="30%" height="80%" style="background-color:#0033CC">左菜单</td>
            <td width="70%" height="80%" style="background-color:#FF00FF">右菜单</td>
        </tr>
        <tr>
            <td width="100%" height="10%" colspan="2" style="background-color:#FF0000">这是底部</td>
        </tr>
    </table>
</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值