absolute与relative的区别

<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
#Layer1 {
 width:100px;
 height:100px;
 z-index:3;
 position:absolute;
 background-color: #FF0000;
 top: 0px;
 left: 50px;
 padding-top: 10px;
 padding-left: 150px;
 margin: 50px;
}
#Layer2 {
 z-index:2;
 position:relative;
 background-color: #CCCCCC;
 left: 50px;
 top: 0px;
}
#Layer3 {
 z-index:1;
 position:relative;
 background-color: #0000FF;
 left: 50px;
 top: 0px;
}
-->
</style>
</head>
<body>

<p>123333333333333333333333333333333333444444444444</p>
<div id="Layer3">Layer3<br>
  Layer3<br>
  <div id="Layer2">Layer2<br>
    Layer2<br>
    <div id="Layer1">Layer1<br>
      Layer1<br>
      Layer1<br>
      Layer1<br>
    </div>
    Layer2<br>
    Layer2<br>
  </div>
  Layer3<br>
  Layer3<br>
</div>
</body>
</html>

 

 

===========================

sPositionString that specifies or receives one of the following values.
staticDefault. Object has no special positioning; it follows the layout rules of HTML.
absoluteObject is positioned relative to parent element's position—or to the body object if its parent element is not positioned—using the top and left properties.
relativeObject is positioned according to the normal flow, and then offset by the top and left properties.

statict 正常工作流,left, op失效,

absolute相对于parent元素,left, top有效,如果left, top没value,或叫null,则left,top,ie产生一个值,其值等于正常工作流时的top, left(如日期控件是display,其定义一般是当前元素的postion底部+10,或mouse postion)

relative, 正常工作流,即上一次元素的,top. left有效

现在ie7已解决select的问题,这点与ff相近,box盒子定义也是如些,这点与ie6不同,以后再测试....

 padding-top: 10px;
 padding-left: 150px;
 margin: 50px;

借助dw可以清楚其值

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值