当前位置:网站首页>scroll系列
scroll系列
2022-07-19 05:04:00 【qiaokelizhuzhu】
scroll与 client 的区别
scrollWidth/scrollHeight 宽高度 包含了padding 值 不包含 marging和border 值
client 元素被 定义的宽高度
scroll元素自身实际的宽高度不含边框 返回数值不带单位
html代码
<div>1.JavaScript基础从变量的定义与使用、流程控制语句、数组、函数、构造函数、内置对象以及对象等 2.web API 讲解如何获取DOM元素,如何操作DOM 元素,BOM操作 移动端制作网页特效 3. 后面还会有js高级,ES6类面向对象语法,面向对象案例,原型和原型链等等。 4. 还有会jquery 综合 + echarts数据可视化</div>
css样式
div{
width:200px;height:200px;border:solid 5px #f06;overflow:scroll;padding:20px;}
js代码测试
var div = document.querySelector('div')
console.log(div.scrollWidth); //240
console.log(div.scrollHeight); //380
console.log(div.clientWidth); //240
console.log(div.clientHeight); //240
scroll 滚动事件当我们滚动条发生变化 会触发的事件
div.addEventListener('scroll', function() {
//上面被卷的高度
console.log(div.scrollTop); //87
//侧面被卷的高度
console.log(div.scrollLeft);//0
})
边栏推荐
- 数据在内存中的存储
- C语言实现通讯录
- 指针数组和数组指针有什么区别?
- MySQL data specifies the field name and field remarks of the data table through SQL query
- MySQL gets the start time and end time of the current day, yesterday, this week, last week, this month and last month
- Student achievement management system (C language)
- Using function pointer array to write calculator
- C語言實現通訊錄
- Interval coverage problem
- 用C实现三种版本的通讯录
猜你喜欢
随机推荐
The longest common subsequence of order 2 and order n
嵌入式软件工程师
Character functions and string functions
八皇后问题,秒懂递归回溯(有图详解|c语言)
巩固复习之指向函数指针数组的指针、回调函数
学习日记1
Pytorch target detection competition (I) data analysis
字符串逆序的几种写法
C语言实现通讯录
Yolov5 bird detection
yolov3训练自己的数据集
Share what you learned this week - detailed explanation of transformer model
三子棋游戏
第七十二:行人检测
Pytorch implements the use of data enhancement classification evaluations
学习日记-指针专题
4000 words, let you understand recursion and its example practice (C language, with pictures)
枚举(enum)奇妙的使用、联合体(共用体union)对空间节省的巧妙
第六十二篇:win10上运行VS程序出现蓝屏崩溃
我的第一篇博客