jQuery-尺寸方法

  • width()  --  设置或返回元素的宽度(不包含内边距、边框或外边距)
  • height()  --  设置或返回元素的高度(不包含内边距、边框或外边距)
  • innerWidth()  --  返回元素的宽度(包含内边距,不包含边框或外边距)
  • innerHeight()  --  返回元素的高度(包含内边距,不包含边框或外边距)
  • outerWidth()  --  返回元素的宽度(包含内边距,边框。如果传进去true,则包含外边距)
  • outerHeight()   --  返回元素的宽度(包含内边距,边框。如果传进去true,则包含外边距)

   唯一需要注意的地方,设置了 box-sizing 后,width() 获取的是 css 设置的 width 减去 padding 和 border 的值。

.test{100px;height:100px;padding:10px;border:10px;box-sizing:border-box;}
  •  width() 获取为: 60
  •  innerWidth() 获取值为: 80
  •  outWidth() 获取值为: 100
原文地址:https://www.cnblogs.com/mwxz/p/13597452.html