如何用CSS样式进行网页布局
来源:互联网 发布:sql查询第几位数据 编辑:程序博客网 时间:2024/06/05 05:15
1 分栏又称为分列,常见的布局分为:
一列布局 两列布局 三列布局 混合布局
(1)一列布局:
<!DOCTYPE html><html><head><meta http-equiv="Comtent-Type" content="text/html" charset="utf-8"><title>布局</title><style type="text/css">body{margin:0; padding: 0;}.top{height: 100px;background: blue;}.main{width: 800px; height: 300px;background: #ccc;margin: 0 auto;}.foot{width: 800px;height: 100px;background: #900;margin: 0 auto;}</style></head><body> <div class="top"></div> <div class="main"></div> <div class="foot"></div></body></html>margin:0 auto; //让元素居中显示
(2) 两列布局:
<!DOCTYPE html><html><head><meta http-equiv="Comtent-Type" content="text/html" charset="utf-8"><title>布局</title><style type="text/css">body{margin:0; padding: 0;}.main{width: 800px;margin: 0 auto;}.left{width: 220px;height: 500px;float:left;background: #ccc;}.right{width: 580px;height: 500px;float: right;background: #ddd;}</style></head><body><div class="main"> <div class="left"></div> <div class="right"></div> </div></body></html>float:left(right);//浮动靠左或者右
(3) 三列布局:
<!DOCTYPE html ><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>三列布局</title> <style type="text/css"> body{ margin:0; padding:0; font-size:30px; font-weight:bold} div{ line-height:50px} .left{ width:200px; height:600px; background:#ccc; position:absolute; left:0; top:0} .main{ height:600px; margin:0 310px 0 210px; background:#9CF} .right{ height:600px; width:300px; position:absolute; top:0;right:0; position:absolute; background:#FCC;}</style></head><body> <div class="left">left</div> <div class="main">设计首页的第一步是设计版面布局。就象传统的报刊杂志编辑一样,我们将网页看作一张报纸,一本杂志来进行排版布局。 虽然动态网页技术的发展使得我们开始趋向于学习场景编剧,但是固定的网页版面设计基础依然是必须学习和掌握的。它们的基本原理是共通的,你可以领会要点,举一反三。</div> <div class="right">right</div></body></html>(4) 混合布局
<!DOCTYPE html><html><head><meta http-equiv="Comtent-Type" content="text/html" charset="utf-8"><title>流式布局</title><style type="text/css">body{margin:0; padding: 0;}.top{height: 100px;background: blue;}.head{height: 100px;width: 800px;background: #f60;margin: 0 auto;}.main{width: 800px; height: 600px;background: #ccc;margin: 0 auto}.left{width: 200px;height: 600px;background: yellow;float: left;}.right{width: 600px;height: 600px;background: #369;float: right;}.sub_l{width: 400px;height: 600px;background: green;float: left;}.sub_r{width: 200px;height: 600px;background: #09F;float: right;}.foot{width: 800px;height: 100px;background: #900;margin: 0 auto}</style></head><body> <div class="top"> <div class="head"></div> </div> <div class="main"> <div class="left"> </div> <div class="right"> <div classs="sub_l"> </div> <div class="sub_r"> </div> </div> </div> <div class="foot">300px</div> </body></html>
阅读全文
0 0
- 如何用CSS样式进行网页布局
- 如何用CSS进行网页布局
- 如何用css进行网页布局<mooc>
- [练习]如何用CSS进行网页布局
- 慕课网《如何用CSS进行网页布局》视频学习笔记
- 第 1 章 如何用 CSS 进行网页布局
- 【慕课网】如何用CSS进行网页布局--挑战编程作业
- 小白笔记之如何用CSS进行网页布局(一) 一列布局
- 小白笔记之如何用CSS进行网页布局(二) 两列布局
- 如何用CSS控制超链接字体样式
- 如何用JS来增加CSS样式
- 如何用div+css布局页面
- 如何用div+css布局页面
- 如何用div+css布局页面
- 如何用div+css布局页面
- [转]如何用div+css布局页面
- 如何用css设置网页字体
- 如何用css设置网页字体
- 【JavaSE学习笔记】for循环的嵌套与跳转控制语句
- 实体bean放进list集合值重复的问题
- python写算法题:leetcode: 11. Container With Most Water
- virtualbox 扩展虚拟机硬盘大小
- JSP中页面自动定时刷新
- 如何用CSS样式进行网页布局
- Java接口使用心得
- Object类的九个方法
- 常用ntp服务器地址
- 微信小程序:商城系列专辑(开发指南+精品Demo)
- Javaweb学习笔记---Servlet相关类
- UI
- String StringBuffer StringBuilder类
- CodeForces