首页 > 作文

css 元素实际宽高

更新时间:2023-04-07 04:27:13 阅读: 评论:0

首先定义一个div

然发音用英语怎么说后稍微装修一下

下面开始区分

一、clientwidthclientheigh clienttopclientleft

1clientwidth的实际宽度

clientwidth =width+左右padding

2clientheigh的实际高度

clientheigh = height + 上下padding

3clienttop的实际宽度

clienttop = boder.top(上边框的宽度)

4clientleft的实际宽度

clientleft = boder.left(左边框的宽度)

二、offtwidthoffthight offttopofftleft

1,offtwidth的实际宽度

offtwidth = width + 左右padding + 左右boder

2,offtheith的实际高度法学在职研究生

offtheith = height + 上下padding + 上下boder

3offttop实际宽度

offttop:当前元素 上边框 外边缘 到 最近的已定位父级(offtparent) 上边框 内边缘的 距离。如果父

级都没有定位,则分别是到body 顶部 和左边的距离

4offtleft实际宽度

offtleft:当前元素 左边框 外边缘 到 最近的已定位父级(offtparent) 左边框 内边缘的 距离。如果父级都没有定位,则分别是到body 顶部 和左边的距离

三、scrollwidthscrollheight scrolltopscrollleft

1scrollwidth实际宽度

scrollwidth:获取指定标签内容层的真实宽度(可视区域宽度+被隐藏区域宽度)。

2scrollheight的实际高度

scrollheight:获取指定标签内容层的真实高度(可视区域高度+被隐藏区域高度)

3scrolltop

李泽航

scrolltop :内容层顶部 到 可视区域顶部的距离。

实例:

var scrolltop = document.docume新疆喀纳斯ntelement.scrolltop || window.pageyofft || document.body.scrolltop;

持续获取高度的方式:

window.addeventlistener('scroll', ()=>{  var scrolltop = document.documentelement.scrolltop || window.pageyofft || document.body.scrolltop;});

4scrollleft

scrollleft:内容层左端 到 可视区域左端的距离.

本文发布于:2023-04-07 04:27:12,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/9146b020a7d8d491078c0fd11b9bd37f.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:css 元素实际宽高.doc

本文 PDF 下载地址:css 元素实际宽高.pdf

标签:宋体   宽度   边框   高度
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图