与对象定位的相关属性

<!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>
</head>
<body style="margin:100px;padding:0;background:#000;position:relative;width:1000px;padding:100px;height:1000px;border:solid 50px #0f0;">
<div id="container" style="width:300px;height:100px;background:#00f;top:0;border:10px solid #f00;padding:20px;margin:100px;position:absolute;left:200px;overflow:scroll;">
   <div style="padding:0;margin:0;left:0;top:0;positon:static;width:500px;height:500px;overflow:hidden;"> width:300px;height:100px;dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
    asdfljasldfkja
    asdlfjasdlfjka
    asdlfjalsdjf
    asdlfja;sldfjk
    asdlfjas;ldkfj
    asdlfjas;ldkjf
    asdlfjas'dlfjalsdjkf
    adslfjasldfkjalsdkjf
    asdlfkjasldfkjalsdkjf
    </div>
</div>
<script type="text/javascript">
$=document.getElementById("container");
alert($.scrollHeight+" "+$.scrollWidth);
</script>
</body>
</html>

 

 

 

 

 

clientLeft 10 边框宽

clientTop 10

clientWidth 323 可见区域宽(背景可见),包括内边距

clientHeight 123

 

offsetWidth 360

offsetHeight 160 包括边框

offsetLeft 300 包括边界 有定位元素时,从定位元素的内边距开始算起

offsetTop 100

style.left 不包括边界, 开发者给的                

style.width:开发者给的宽度

 

scrollHeight 540包括整个可以通过滚动可见的。为什么在IE下是520,而FF下是540,padding的影响?FF下不会将右边距算进去,去掉padding之后二者一致,都成了500

scrollLeft 0

scrollTop 0

scrollWidth 520 ;两者一样。

 

 

<html>,即document.documentElement,尽管可以有样式width,height,但clientWidth,clientHeight总是会与浏览器可见区域大小保持一致。

<body>,即document.body,可以应用任何CSS样式。

转载于:https://www.cnblogs.com/fredwu/archive/2012/03/25/2416874.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值