jQuery中关于height,innerWidth与outerWidth的区别
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了jQuery中关于height,innerWidth与outerWidth的区别,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1985字,纯文字阅读大概需要3分钟。
内容图文
jQuery width() 和 height() 方法
width() 方法设置或返回元素的宽度(不包括内边距、边框或外边距)。
height() 方法设置或返回元素的高度(不包括内边距、边框或外边距)。
jQuery innerWidth() 和 innerHeight() 方法
innerWidth() 方法返回元素的宽度(包括内边距)。
innerHeight() 方法返回元素的高度(包括内边距)。 公式为height()+padding*2
jQuery outerWidth() 和 outerHeight() 方法
outerWidth() 方法返回元素的宽度(包括内边距和边框)。
outerHeight() 方法返回元素的高度(包括内边距和边框)。 公式为height()+padding*2+边框*2
outerWidth(true) 方法返回元素的宽度(包括内边距、边框和外边距)。
outerHeight(true) 方法返回元素的高度(包括内边距、边框和外边距)。 公式为height()+padding*2+边框*2+margin*2
实际例子:
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > < html xmlns ="http://www.w3.org/1999/xhtml" > < head > < meta http-equiv ="Content-Type" content ="text/html; charset=gb2312" /> < script src ="jQuery/jquery-1.6.4.js" type ="text/javascript" ></ script > < script type ="text/javascript" > $( function (){ $( " div " ).html( " innerHeight= " + $( " div " ).innerHeight() + " <br />innerWidth= " + $( " div " ).innerWidth()); $( " div " ).html( $( " div " ).html() + " <br />Height= " + $( " div " ).height() + " <br />Width= " + $( " div " ).width()); $( " div " ).html( $( " div " ).html() + " <br />outerHeight= " + $( " div " ).outerHeight() + " <br />outerWidth= " + $( " div " ).outerWidth()); $( " div " ).html( $( " div " ).html() + " <br />outerHeight(true)= " + $( " div " ).outerHeight( true ) + " <br />outerWidth(true)= " + $( " div " ).outerWidth( true )); }) </ script > < style type ="text/css" > div { width : 300px ; height : 50px ; margin : 50px ; padding : 50px ; border : solid 50px red ; } </ style > < title >demo</title></head><body><div style="border:solid 10px red;">box</div></body></html>
运行效果:
原文:http://www.cnblogs.com/YEKEYISHUO/p/3903651.html
内容总结
以上是互联网集市为您收集整理的jQuery中关于height,innerWidth与outerWidth的区别全部内容,希望文章能够帮你解决jQuery中关于height,innerWidth与outerWidth的区别所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。