当前位置:网站首页>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
边栏推荐
- 使用知行之桥的API端口,提供资源供合作伙伴访问
- 綠竹生物沖刺港股:年期內虧損超5億 泰格醫藥與北京亦莊是股東
- 宝宝巴士创业板IPO被终止:曾拟募资18亿 唐光宇控制47%股权
- 2322. Remove the minimum fraction of edges from the tree (XOR and & Simulation)
- lsf基础命令
- Experience home office, feel the completion of the project | community essay solicitation
- executescalar mysql_ ExecuteScalar()
- Error when uploading code to remote warehouse: remote origin already exists
- 绿竹生物冲刺港股:年期内亏损超5亿 泰格医药与北京亦庄是股东
- Use of openpose
猜你喜欢
剑指 Offer 26. 树的子结构
[error record] error -32000 received from application: there are no running service protocol
871. 最低加油次数
Timing / counter of 32 and 51 single chip microcomputer
Qstype implementation of self drawing interface project practice (II)
What if the default browser cannot be set?
Experience home office, feel the completion of the project | community essay solicitation
Listing of chaozhuo Aviation Technology Co., Ltd.: raising 900million yuan, with a market value of more than 6billion yuan, becoming the first science and technology innovation board enterprise in Xia
Jiuxian's IPO was terminated: Sequoia and Dongfang Fuhai were shareholders who had planned to raise 1billion yuan
13、Darknet YOLO3
随机推荐
一年顶十年
2322. Remove the minimum fraction of edges from the tree (XOR and & Simulation)
深度之眼(二)——矩阵及其基本运算
IP address translation address segment
电脑自带软件使图片底色变为透明(抠图白底)
The impact of telecommuting on all aspects of our experience | community essay solicitation
The poor family once again gave birth to a noble son: Jiangxi poor county got the provincial number one, what did you do right?
QWebEngineView崩溃及替代方案
What will you do after digital IC Verification?
VMware install win10 image
LeetCode:1380. Lucky number in matrix -- simple
ThreadLocal
亚马逊云科技 Community Builder 申请窗口开启
How to quickly distinguish controlled components from uncontrolled components?
OpenPose的使用
dstat使用[通俗易懂]
Detailed explanation of @accessories annotation of Lombok plug-in
社交元宇宙平台Soul冲刺港股:年营收12.8亿 腾讯是股东
lsf基础命令
【征文活动】亲爱的开发者,RT-Thread社区喊你投稿啦