position:relative 不知道第三个怎样显示

lianglinm 2007-12-15 03:30:20
<body leftmargin="0" topmargin="0">
<div id=div1 style="POSITION:relative; width: 100px; left: 50px; top: 97px;">
<div id=div2 style="position:relative;width:100px;left:10px;top:10px;background-color:red;"> Inner caption</div>

<div id=div3 style="position:relative;left:10px;top:10px;background-color:#FFFF33 ">
this div is relatived to which??</div>

</div>
</body>
...全文
19 点赞 收藏 3
写回复
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lianglinm 2007-12-15
好的 谢了。。
回复
yixianggao 2007-12-15
relative要慎用,多用magin或padding吧!
L@_@K
]<!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>
<title>new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="yixianggao@126.com" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
</head>
<body leftmargin="0" topmargin="0">
<div id="div1" style="position: relative; width: 100px; left: 50px; top: 100px; border: 1px dotted blue;">
<div id="div2" style="margin: 10px 0px 0px 10px; background-color: red;">
 Inner caption<br />
 Inner caption<br />
 Inner caption<br />
</div>
<div id="div3" style="margin: 10px 0px 0px 10px; background-color: #FFFF33">
this div is relatived to which??
</div>
</div>
</body>
</html>
回复
yixianggao 2007-12-15
div3是相对于div1而言滴,left就可以证明,而top滴计算似乎有些奇怪,
下面div3的top: 20px,其实是10+10,最好再仔细查查手册!
<!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>
<title>new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="yixianggao@126.com" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
</head>
<body leftmargin="0" topmargin="0">
<div id="div1" style="position: relative; width: 100px; left: 50px; top: 100px; border: 1px dotted blue;">
<div id="div2" style="position: relative; width: 100px; left: 10px; top: 10px; background-color: red;">
 Inner caption<br />
 Inner caption<br />
 Inner caption<br />
</div>
<div id="div3" style="position: relative; left: 10px; top: 20px; background-color: #FFFF33">
this div is relatived to which??
</div>
</div>
</body>
</html>
回复
发动态
发帖子
CSS
创建于2007-09-28

5.9w+

社区成员

层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
申请成为版主
社区公告
暂无公告