CSS网页布局
来源:互联网 发布:cf 显示网络异常Tp 编辑:程序博客网 时间:2024/05/16 14:28
网页布局有各种各样的方式,这里简单说几种典型常用的布局。
- 单列布局
单列布局的话,一般为一个header 一个Main 和一个footer组成。通常用作网站的主页。
代码实现:
<html xmlns="http://www.w3.org/1999/xhtml"><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}div{ text-align:center; font-weight:bold}.main,.footer{ width:960px; }.head{ width:100%; height:100px; background:#ccc}.main{ height:600px; background:#FCC; margin:0 auto;}.footer{ height:50px; background:#9CF; margin:0 auto;}</style></head><body><div class="head">head</div><div class="main">main</div><div class="footer">footer</div></body></html>
其中margin 0 auto 实现了 Main 和 foote居中显示的作用。
- 两列布局
两列布局格局与单列的差别在于,在Main中 包含了 Left 和Right 两个部分 。 实现代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><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{ text-align:center; line-height:50px}.main{ width:960px; height:600px; margin:0 auto}.left{ width:300px; height:600px; background:#ccc; float:left;}/*左浮动样式*/.right{ width:660px; height:600px; background:#FCC; float:right;}/*右浮动样式*/</style></head><body><div class="main"> <div class="left">left</div> <div class="right">right</div></div></body></html>
用float 实现左右浮动 实现二列布局
- 三列布局
<html xmlns="http://www.w3.org/1999/xhtml"><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; right:0;top:0; position:absolute; background:#FCC;}</style></head><body> <div class="left">left</div> <div class="main">设计首页的第一步是设计版面布局。就象传统的报刊杂志编辑一样,我们将网页看作一张报纸,一本杂志来进行排版布局。 虽然动态网页技术的发展使得我们开始趋向于学习场景编剧,但是固定的网页版面设计基础依然是必须学习和掌握的。它们的基本原理是共通的,你可以领会要点,举一反三。</div> <div class="right">right</div></body></html>
首先让left 和right 设置绝对位置 position, 之后再确定Main的大小
0 0
- 网页布局--CSS网格布局
- 利用CSS布局网页
- css网页布局
- css网页布局
- CSS网页布局
- CSS网页布局经验
- CSS+DIV网页布局
- div+css 网页布局
- CSS网页布局
- div+css 网页布局
- CSS网页布局基础
- css网页布局基础
- css网页布局
- CSS网页布局模型
- css网页布局
- CSS网页布局基础
- CSS网页布局
- css网页布局例子
- 小工具DeTexturepacker
- Java中的设计模式学习总结(二)---单例模式
- 使用Unity来学习OpenGL
- 初创团队配置_咨询整理(熊猫TV首席架构师)
- 二叉堆(binary heap)—— 优先队列的实现
- CSS网页布局
- PHP正则表达式(汇总+理解+实用例子)
- Linux shutdown 命令详解
- python标准模块学习5_______uuid模块
- Shader技巧集合
- SQL语句
- SVN和Git简单介绍
- 版本跟新 导入类名 Conf
- 关于学习jquery