惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
WordPress大学
WordPress大学
C
Check Point Blog
GbyAI
GbyAI
U
Unit 42
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
I
InfoQ
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Hugging Face - Blog
Hugging Face - Blog
Vercel News
Vercel News
博客园 - 【当耐特】
美团技术团队
小众软件
小众软件
S
SegmentFault 最新的问题
Jina AI
Jina AI
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog

博客园 - Richinger

纪念我的二姐 Myeclipse8.5快速注册 C#字符串数组的奇怪现象 - Richinger - 博客园 中国建设银行乐当家理财卡权益积分计算方法 ASP.NET网页之间复杂参数传递方法 - Richinger - 博客园 iis6.0添加asp.net 3.5网站 出现“HTTP 错误 404 - 文件或目录未找到”的解决办法 net2003 "visual studio.net 无法加载,因为无法加载MSXML3.DLL文件"的解决办法 民革九江第一支部星子活动纪实 使用oledb读写excel出现“操作必须使用一个可更新的查询”的解决办法 找不到可安装的ISAM - Richinger - 博客园 网站根目录下没有正确的DNT.config文件 解决办法 - Richinger - 博客园 HTTP 500 - 内部服务器错误 解决办法 中国建设银行国际结算业务介绍 高端客户业务 中国建设银行总行招聘信息技术及有关人员 LOGO1_.exe病毒及清理 九江名称的来历 asp.net也可以这样调用js 中国建设银行招聘公告
DIV+css定位 - Richinger - 博客园
Richinger · 2009-12-03 · via 博客园 - Richinger

请大家看看如下的定义及排出的结果:

代码

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<style>
#container 
{margin:0 auto; width:100%;background:#ff0000;}
#div1 
{ height:300px; width:100px; background:#9c6; margin-bottom:0px;}
#div2 
{ height:100px; width:100px; background:#0c6; margin-left:100px; margin-top:-300px;}

#div3 

{ height:50px; width:80px; background:#009c60;margin-left:100px; margin-top:}
#div4 
{ height:100px; width:100px; background:#00c600;margin-left:100px;  }

#div5 

{ height:100px; width:200px; background:#c6ff00;margin-left:200px; margin-top:-250px; }

#div6 

{ height:200px; width:100px; background:#ffc600;margin-left:100px;margin-top:150px;  }
#div8 
{ height:200px; width:100px; background:#ff00ff;margin-left:300px; margin-top:-350px;}
#div7 
{ height:200px; width:100px; background:#ffc600;margin-left:400px;margin-top:-300px;}

#header 

{ height:100px; background:#9c6; margin-bottom:0px;}
#menu 
{ height:20px; background:#693; margin-bottom:0px;}
#mainContent 
{ background:url(bg.gif) 0 0 repeat-y; overflow:auto;zoom:1; margin-bottom:1px;}
#sidebar 
{ float:left; width:200px;background:#cf9; height:auto !important; height:100px;}
#content 
{ margin-left:205px !important; margin-left:202px; height:auto !important; height:100px; background:#ffa;}
#footer 
{ height:60px; background:#9c6;}
.clearfloat 
{ clear:both; height:0; font-size: 1px; line-height: 0px;}</style>
</head><body>
<div id="container" >
<div id="div1">div1</div>
<div id="div2">div2</div>
<div id="div3">div3</div>
<div id="div4">div4</div>
<div id="div5">div5</div>
<div id="div6">div6</div>
<div id="div8">div8</div>
<div id="div7">div7</div></div>
<div style="position: absolute; width: 100px; height: 100px; z-index: 1; left: 379px; top: 245px" id="layer1">
 
</div>
</body></html>

   特别注意div1-8在container中出现的先后次序再对照定义,或许会有些感悟。