您好,欢迎访问一九零五行业门户网

浅谈jQuery中height与width_jquery

jquery中有三个获取element高度的方法,分别是:height(),innerheight(),outerheght(bool);同样对应的有三个获取element宽度的方法:width(),innerheight(),outerheight(bool),这三个方法分别对应怎样的元素属性,如下图所示:
从上面的图可以了解到:height()方法对应顶部style设置的width属性;
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;
来个简单的示例吧
hello
w3school
请点击这里
以上所述就是本文的全部内容了,希望大家能够喜欢。
其它类似信息

推荐信息