在获取容器尺寸的时候,一定要分清是内部尺寸还是外部尺寸,特别是在使用一些框架的时候,本身会默认带一些边距,如果不注意很容易出现bug且不易查找,具体区别如下所示:
- height(): 其高度范围是所匹配元素的高度height;
- innerHeight(): 其高度范围是所匹配元素的高度height+padding;
- outerHeight(): 其高度范围是所匹配元素的高度height+padding+border;
- outerHeight(true): 其高度范围是所匹配元素的高度height+padding+border+margin;
- 水平宽度的获取同高度,不再赘述
原文作者:Jesse131
原文出处:https://www.cnblogs.com/jesse131/p/5111191.html#undefined