当前位置:网站首页>Introduce the scrollintoview() method attribute in detail
Introduce the scrollintoview() method attribute in detail
2022-07-02 17:20:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Because the anchor point setting is used in the work , Common ones always go wrong , Later, I pulled out this attribute , Studied in detail for future use
Introduce scrollIntoView() Detailed properties of
brief introduction
The scrollIntoView() Method scrolls the element calling it to the visible area of the browser window .
PS: According to the layout of other elements , Elements may not scroll completely to the top or bottom .
TIPS: page ( Containers ) Useful when scrollable !
grammar
element.scrollIntoView(); // Equate to element.scrollIntoView(true)
element.scrollIntoView(alignToTop); // Boolean parameters
element.scrollIntoView(scrollIntoViewOptions); // Object parameters Syntax parameters
alignToTop | [ Optional ], At present, this parameter has been well supported |
|---|---|
true | The top of the element will be aligned to the top of the visible area of the scrollable ancestor . Corresponding to scrollIntoViewOptions: {block: "start", inline: "nearest"}. This is the default |
false | The bottom of the element will align with the bottom of the visible area of the scrollable ancestor . Corresponding to scrollIntoViewOptions: {block: "end", inline: "nearest"}. |
scrollIntoViewOptions | [ Optional ], At present, this parameter browser does not support it well , You can view the compatibility details below |
|---|---|
behavior | [ Optional ] Define transition animation ."auto","instant" or "smooth". The default is "auto". |
block | [ Optional ] "start","center","end" or "nearest". The default is "center". |
inline | [ Optional ] "start","center","end" or "nearest". The default is "nearest". |
Example
var element = document.getElementById("box");
element.scrollIntoView();
element.scrollIntoView(false);
element.scrollIntoView({block: "end"});
element.scrollIntoView({behavior: "instant", block: "end", inline: "nearest"});Application scenarios
URL in hash Evolution of markers
- The chat window scrolls through the latest messages
- Add to a list item Scroll back to show the latest added item
- Back to the top (#)
- Scroll to the specified position (#xxx)
Browser compatibility
features | Chrome | Firefox | Safari | Edge | IE | Opera |
|---|---|---|---|---|---|---|
Basic support ( alignToTop ) | yes | yes | yes | yes | yes | yes |
scrollIntoViewOptions | yes | yes | 5.1[1] | 12[1] | 9[1] | 48[2] |
Be careful : I won't support it "smooth" Act or "center" Options .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/148024.html Link to the original text :https://javaforall.cn
边栏推荐
- How to transfer business data with BorgWarner through EDI?
- Eye of depth (II) -- matrix and its basic operations
- Visibilitychange – refresh the page data when the specified tab is visible
- Tech talk activity preview | building intelligent visual products based on Amazon kVs
- 【征文活动】亲爱的开发者,RT-Thread社区喊你投稿啦
- JS delete substring in string
- Experience home office, feel the completion of the project | community essay solicitation
- 2022 interview questions
- 【Leetcode】14. 最長公共前綴
- The impact of telecommuting on all aspects of our experience | community essay solicitation
猜你喜欢

社交元宇宙平台Soul冲刺港股:年营收12.8亿 腾讯是股东

Sword finger offer 24 Reverse linked list

Linux Installation PostgreSQL + Patroni cluster problem

Amazon cloud technology community builder application window opens

綠竹生物沖刺港股:年期內虧損超5億 泰格醫藥與北京亦莊是股東

Weili holdings listed on the Hong Kong Stock Exchange: with a market value of HK $500million, it contributed an IPO to Hubei

Sword finger offer 25 Merge two sorted linked lists

深度之眼(二)——矩阵及其基本运算

Qwebengineview crash and alternatives
![[leetcode] 14. Préfixe public le plus long](/img/70/e5be1a7c2e10776a040bfc8d7711a0.png)
[leetcode] 14. Préfixe public le plus long
随机推荐
2322. Remove the minimum fraction of edges from the tree (XOR and & Simulation)
AP and F107 data sources and processing
Nexus簡介及小白使用IDEA打包上傳到Nexus3私服詳細教程
剑指 Offer 25. 合并两个排序的链表
P6774 [noi2020] tears in the era (block)
Cell: Tsinghua Chenggong group revealed an odor of skin flora. Volatiles promote flavivirus to infect the host and attract mosquitoes
【Leetcode】14. 最長公共前綴
Blog theme "text" summer fresh Special Edition
几行代码搞定RPC服务注册和发现
超卓航科上市:募资9亿市值超60亿 成襄阳首家科创板企业
R and rstudio download and installation tutorial (super detailed)
The beginning of life
How to quickly distinguish controlled components from uncontrolled components?
Soul, a social meta universe platform, rushed to Hong Kong stocks: Tencent is a shareholder with an annual revenue of 1.28 billion
Eth data set download and related problems
VMware install win10 image
Dstat use [easy to understand]
IDEA2021.1 安装教程
One year is worth ten years
一年頂十年