height、clientHeight和offsetHeight之间的区别
文章目录
innerHeight 返回窗口的文档显示区的高度。
innerWidth 返回窗口的文档显示区的宽度。
this.innerHeight=window.innerHeight;
window.addEventListener("resize", ()=> {
if(window.innerHeight<this.innerHeight){
this.bothshow=false;
}else{
this.bothshow=true;
}
})height:指元素内容的高度,jQuery中的height()方法返回的就是这个高度。
clientHeight:内容高度+padding高度,jQuery中的innerHeight()方法返回的就是这个高度。
offsetHeight:内容高度+padding高度+边框宽度,jQuery中的outerHeight()方法返回的就是这个高度。
width:指元素内容的宽度,jQuery中的width()方法返回的就是这个宽度。
clientWidth:内容高度+padding宽度,jQuery中的innerWidtht()方法返回的就是这个宽度。
offsetWidth:内容高度+padding高度+边框宽度,jQuery中的outerWidth()方法返回的就是这个宽度。

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论