当前位置:网站首页>js滚动条滚动到指定元素
js滚动条滚动到指定元素
2022-07-31 09:10:00 【aら 淼】
let item = document.getElementById("item"); // 指定的元素
let wrapper = document.getElementById("wrapper"); // 其父元素 - 必须是产生滚动条的元素
// 元素聚焦法定位
// item.focus(); // 可用 outline:none; 除去聚焦产生的框; 对于默认没有聚焦的元素需要主动添加属性:如tabindex="222" 需唯一
// 父组件滚动法
wrapper.scrollTo(item.offsetLeft, 0); // 横向
wrapper.scrollTo(0 , item.offsetTop); // 竖向
- item:指定的元素
- wrapper:其父元素 - 必须是产生滚动条的元素
- 元素聚焦法定位:item.focus();除去聚焦产生的框; 对于默认没有聚焦的元素需要主动添加属性:如tabindex=“222” 需唯一。
- 父组件滚动法:
- wrapper.scrollTo(item.offsetLeft, 0); // 横向
- wrapper.scrollTo(0 , item.offsetTop); // 竖向
边栏推荐
- 【Excel】生成随机数字/字符
- Small application project development, jingdong mall 】 【 uni - app custom search component (below) - search history
- 如何将亚马逊广告添加到您的 WordPress 网站(3 种方法)
- 状态机动态规划之股票问题总结
- MySQL 排序
- 来n遍剑指--09. 用两个栈实现队列
- 7. JS ES6新增语法 new Map详讲,还有一道代码实战案例帮你快上手new Map
- 0730~Mysql optimization
- Pytorch学习记录(七):自定义模型 & Auto-Encoders
- 【Redis高手修炼之路】Jedis——Jedis的基本使用
猜你喜欢
0730~Mysql optimization
[Yellow ah code] Introduction to MySQL - 3. I use select, the boss directly drives me to take the train home, and I still buy a station ticket
js空气质量aqi雷达图分析
How to upgrade nodejs version
MUI获取相机权限
优信年营收16亿:亏损3亿 已与蔚来资本及58集团签署股权协议
期刊投递时的 Late News Submission 是什么
Flink1.15源码阅读——PER_JOB vs APPLICATION执行流程
科目三:左转弯
Define event types in Splunk Web
随机推荐
[NLP] Interpretation of Transformer Theory
【软考软件评测师】2012综合知识历年真题
ReentrantLock
JSP response,request操作中(中文乱码)-如何解决呢?
js right dot single page scrolling introduction page
手写promise
利用frp服务器进行内网穿透ssh访问
比较并交换 (CAS) 原理
Modular specifications
期刊投递时的 Late News Submission 是什么
js空气质量aqi雷达图分析
[Yellow ah code] Introduction to MySQL - 3. I use select, the boss directly drives me to take the train home, and I still buy a station ticket
[Mini Program Project Development--Jingdong Mall] Custom Search Component of uni-app (Middle)--Search Suggestions
Which strings will be parsed as null by FastJson?
第二十二课,实例化(instancing)
HTC官方RUU固件提取刷机包rom.zip以及RUU解密教程
The future of the hybrid interface: conversational UI
C# 正则表达式汇总
A brief introduction to the SSM framework
MySQL----多表查询