失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > HTML+CSS和DIV如何实现排版布局

HTML+CSS和DIV如何实现排版布局

时间:2022-09-27 15:55:59

相关推荐

HTML+CSS和DIV如何实现排版布局

web前端|html教程

php,css,html

web前端-html教程

这篇文章主要介绍了关于HTML+CSS和DIV如何实现排版布局,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

万象源码,ubuntu 打不开 终端,怎么在tomcat上运行,爬虫做海报,nginx运行php的方式,seo太累lzw

HTML CSS + div实现排版布局

1.网页可以看成是由一个一个“盒子”组成,如图:

php简单的在线聊天源码,mac怎么下载ubuntu,爬虫状的脑,php 处理音频,seo设置链接lzw

由上图可以看出,页面分为上(网站导航)、中、下(版权声明)三个部分,

中间部分又分为左(商品分类)、中(主要部分)、右,这些版块就像一个个

的盒子,这些”盒子”中放置着各种内容,页面就是由这些”盒子”拼凑起来

小程序下拉框源码,mac端vscode怎么卸载,ubuntu窗口管理,tomcat配404报错,新闻爬虫版权,php回车符,seo培训哪里最好运营,教育行业网站模板,小米模板lzw

案例布局分析:

单列布局案例:

代码如下:

单列布局body{ margin:0; } .box{ width:960px; margin:0 auto; } .box .header{ height:120px; border:1px solid #f00; line-height:120px; } .box .main{ height:300px; border:1px solid #0f0; line-height:300px; } .box .footer{ height:100px; border:1px solid #00f; line-height:100px; } p{ text-align:center; }

头部

主题

底部

运行结果:

双列布局案例:

代码如下:

双列布局body{ margin:0; } .box{ width:80%; margin:0 auto; overflow:hidden; } .box .left{ width:30%; height:400px; background-color:#0f0; float:left; } .box .right{ width:70%; height:400px; background-color:#f00; float:left; }

运行结果如下图:

三列布局案例:

代码如下:

三列布局body{ margin:0; } .box{ width:960px; margin:0 auto; position:relative; } .box .left{ width:200px; height:400px; background-color:#0f0; position:absolute; } .box .center{ height:400px; background-color:#00f; margin:0 300px 0 200px; } .box .right{ width:300px; height:400px; background-color:#f00; position:absolute; right:0; top:0; }

运行结果如下图:

混合布局案例:

代码如下:

混合布局body{ margin:0; } .box{ width:960px; margin:0 auto; } .header{ height:120px; background-color:#ddd; } .main{ height:400px; background-color:#f00; position:relative; } .main .left{ width:200px; height:400px; position:absolute; left:0; top:0; background-color:#0fccaa; } .main .center{ height:400px; margin:0 305px 0 205px; background-color:#123456; } .main .right{ width:300px; height:400px; position:absolute; right:0; top:0; background-color:#ff0; } .footer{ height:80px; background-color:#ddd; }

运行结果如下图:

如果觉得《HTML+CSS和DIV如何实现排版布局》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。