码迷,mamicode.com
首页 > Web开发 > 详细

jQuery中width、innerWidth、outerWidth的区别

时间:2016-11-17 23:37:22      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:idt   参数   order   border   set   属性   can   .com   计算   

原文:摘自http://www.canaansky.com/blog/107/

在css的盒子模型中,最内部是content area,然后是padding、border、margin

那么width其实就是content area,
innerWidth = width + padding
outerWidth = innerWidth + border

不过,jQuery的outerWidth属性还可以传递一个参数,那么:
outerWidth(true) = outerWidth + margin

稍微有点基础的童鞋应该能很明了地看出来区别了吧。不过这个只是我简单测试的结果,没有做什么特别的测试。若有错误,请纠正。

同理,这个区别同样适用于height、innerHeight、outerHeight;而offset属性是计算到border的位置的哦~

jQuery中width、innerWidth、outerWidth的区别

标签:idt   参数   order   border   set   属性   can   .com   计算   

原文地址:http://www.cnblogs.com/10-8-2016-song/p/6075680.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!