首页 > web前端 > H5教程 > 正文

H5学习之旅-H5的布局(10)

黄舟
发布: 2017-02-17 14:35:58
原创
1361人浏览过

两种实现方式:p和table

p实现布局的方式

代码实例

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>H5布局0</title>
    <style type="text/css">
        body{            margin: 0px;;
        }
        #container{            width:100%;            height: 950px;            background-color: chartreuse;        }
        #heading{            width: 100%;            height: 10%;            background-color: brown;        }
        #content_menu{            width:30%;            height: 80%;            background-color: blue;            float: left;        }
        #content_body{            width: 70%;            height: 80%;            background-color: darkgreen;            float: left;        }
        #footer{            width: 100%;            height: 10%;            background-color: aliceblue;            clear: both;        }

    </style></head><body>
    <p id="container">
        <p id="heading">头部</p>
        <p id="content_menu">内容菜单</p>
        <p id="content_body">内容主体</p>
        <p id="footer">尾部</p>
    </p></body></html>
登录后复制

!!!!!!!float表示从左往右浮动 clear表示清除

效果图

这里写图片描述

Poe
Poe

Quora旗下的对话机器人聚合工具

Poe 607
查看详情 Poe

table布局

代码实例

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>H5布局0</title></head><body>
    <table width="100%" height="950px" style="background-color: chartreuse">
        <tr>
            <td width="100%" height="10%" style="background-color: brown" colspan="3">头部</td>
        </tr>
        <tr>
            <td width="20%" height="80%" style="background-color: aqua">左菜单</td>
            <td width="60%" height="80%" style="background-color: black">主体</td>
            <td width="200%" height="80%" style="background-color:crimson">右菜单</td>
        </tr>
        <tr>
           <td width="100%" height="10%" style="background-color: deeppink" colspan="3">尾部</td>
        </tr>

    </table></body></html>
登录后复制

!!!!注意colspan属性

效果图

这里写图片描述

两种实现方式:p和table

p实现布局的方式

代码实例

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>H5布局0</title>
    <style type="text/css">
        body{            margin: 0px;;
        }
        #container{            width:100%;            height: 950px;            background-color: chartreuse;        }
        #heading{            width: 100%;            height: 10%;            background-color: brown;        }
        #content_menu{            width:30%;            height: 80%;            background-color: blue;            float: left;        }
        #content_body{            width: 70%;            height: 80%;            background-color: darkgreen;            float: left;        }
        #footer{            width: 100%;            height: 10%;            background-color: aliceblue;            clear: both;        }

    </style></head><body>
    <p id="container">
        <p id="heading">头部</p>
        <p id="content_menu">内容菜单</p>
        <p id="content_body">内容主体</p>
        <p id="footer">尾部</p>
    </p></body></html>
登录后复制

!!!!!!!float表示从左往右浮动 clear表示清除

效果图

这里写图片描述

table布局

代码实例

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>H5布局0</title></head><body>
    <table width="100%" height="950px" style="background-color: chartreuse">
        <tr>
            <td width="100%" height="10%" style="background-color: brown" colspan="3">头部</td>
        </tr>
        <tr>
            <td width="20%" height="80%" style="background-color: aqua">左菜单</td>
            <td width="60%" height="80%" style="background-color: black">主体</td>
            <td width="200%" height="80%" style="background-color:crimson">右菜单</td>
        </tr>
        <tr>
           <td width="100%" height="10%" style="background-color: deeppink" colspan="3">尾部</td>
        </tr>

    </table></body></html>
登录后复制

!!!!注意colspan属性

效果图

这里写图片描述

 以上就是H5学习之旅-H5的布局(10)的内容,更多相关内容请关注PHP中文网(www.php.cn)!

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号