jq-height,width

jquery中有三个获取element高度的方法,分别是:height(),innerHeight(),outerHeght(bool);同样对应的有三个获取element宽度的方法:width(),innerHeight(),outerHeight(bool),这三个方法分别对应怎样的元素属性,如下图所示:

从上面的图可以了解到:height()方法对应顶部style设置的height属性;

                              innerHeight()对应width+padding-top+padding-bottom;

                              outerHeight()对应width+padding-top+padding-bottom+border-top+border-bottom;另外看到下面outerHeight与outerWidth的值不一样是由于outerWidth(bool)方法参数被设置成true,这时会加上margin-top和margin-bottom;即:outerWidth = width+padding-top+padding-bottom+border-top+border-bottom+margin-top+margin-bottom;

posted @ 2015-06-07 23:06  这是个坑  阅读(257)  评论(0)    收藏  举报