offsetHeight、offsetWidth
offsetHeight、offsetWidth
offsetHeight
网页可见区域高度 ,offsetWidth
网页可见区域宽度
这两个属性是元素本身的,而不是style
属性里面的,可以通过dom元素点的方式获取
offsetHeight
由height、padding
组成
offsetWidth
由width、padding
组成
实例
<template><div><div class="main" ref="aaa">1111111111111111111111111</div></div>
</template><script>
export default {mounted() {console.log(this.$refs.aaa.offsetHeight,this.$refs.aaa.offsetWidth)},
};
</script><style scoped lang="scss">
.main{width: 50px;padding: 0px 10px;height: auto;background: pink;
}
</style>
从控制台中可以看出:
- 不设置高度时,可以通过offsetHeight获取实际高度,但是你通过style的height属性是获取不到任何数据(宽度同高度一样)
- 可见宽度70=50(width)+ 20(padding)
offsetHeight、offsetWidth相关推荐
- offsetParent、offsetTop、offsetLeft、offsetHeight、offsetWidth
1.offsetParent:获取第一个定位的父元素,如果所有父元素都没有定位,则返回body: <!DOCTYPE html> <html lang="en"& ...
- offsetWidth、offsetHeight、clientHeight、clientWidth、scrollHeight、scrollWidth详细对比
offsetWidth.offsetHeight.clientHeight.clientWidth.scrollHeight.scrollWidth详细对比 代码测试 box-sizing:conte ...
- clientWidth、offsetWidth、clientHeight、offsetHeight的测试比较
clientWidth = width + padding clientHeight = height + padding offsetWidth = width + padding + border ...
- offsetTop、offsetLeft、offsetWidth、offsetHeight、style中的样式
< DOCTYPE html PUBLIC -WCDTD XHTML StrictEN httpwwwworgTRxhtmlDTDxhtml-strictdtd> 假设 obj 为某个 H ...
- clientWidth、clientHeight、offsetWidth、offsetHeight以及scrollWidth、scrollHeight
clientWidth.clientHeight.offsetWidth.offsetHeight以及scrollWidth.scrollHeight是几个困惑了好久的元素属性,趁着有时间整理一下 1 ...
- 四种浏览器对 clientHeight、offsetHeight、scrollHeight、clientWidth、offsetWidth 和 scrollWidth 的解释差异...
转自http://blog.163.com/chudaozhe@126/blog/static/1157323432011626112137928/ 网页可见区域宽:document.body.cli ...
- offsetTop、offsetLeft、offsetWidth、offsetHeight
1.假设 obj 为某个 HTML 控件 obj.offsetTop 指 obj 距离上方或上层控件的位置,整型,单位像素. obj.offsetLeft 指 obj 距离左方或上层控件的位置,整型, ...
- 一篇弄懂 offsetWidth、offsetHeight、offsetleft、offsetTop和offsetParent的区别!(1)
快速理解offset之间的区别 1.offsetWidth与offsetHeight 2.offsetParent 3.offsetleft.offsetTop 以下代码均在Chrome浏览器中测试 ...
- offsetLeft 、offsetWidth、scrollHeight等的区别
一.offsetLeft/offsetTop offsetLeft:元素最左边离最近的有定位的父级之间的距离,不带单位. offsetTop:元素最上边离最近的有定位的父级之间的距离,不带单位. 上图 ...
最新文章
- oracle没什么没有备份,怎么恢复没有备份的Oracle数据库
- mysql+dump+选项_mysqldump的几个主要选项探究
- oracle云产品是什么意思,Oracle云端产品线也要AI化,ERP云等4大主力云产品先升级...
- Bzoj 3680 吊打xxx【[模拟退火】
- 使用SAX解析XML文件
- python函数调用键盘热键_神技能:Python控制键盘鼠标
- 重磅嘉宾公布,第四范式AI新品发布会进入报名倒计时
- ICLR 2020 | 可提速3000倍的全新信息匹配架构(附代码复现)
- java 绝对路径_java 获取绝对路径
- Nexus入门指南(图文)[转]
- LeetCode 876. 链表的中间结点(快慢指针)
- 某计算机系统20位地址线 8位数据线,同济大学2009-2010(1)微机原理期终考试试题(B卷)...
- nodejs express使用HTML模板
- div 设置a4大小_转载 网页打印时设置A4大小
- VTK系列教程九:VR图像裁剪
- C#注册机与绑定软件(转发自:韩兆新的博客园的C#学习笔记——软件注册与注册机)...
- 【C Primer Plus 编程题】里程和耗油量的测量方案
- 程序员能靠纯技术渡过中年危机吗?
- 电商 lamp java_搭建LAMP环境部署Ecshop电商网站
- c语言编程题 8.在一个笼子里同时养着一些鸡和兔子,你想了解有多少只鸡和多少只兔,主人对你说:我只告诉你鸡和兔的总头数是16和总脚数是40,你能不能自己计算有多少只鸡和多少只兔?