![](/img/trans.png)
[英]window.scroll(0,0)/window.scrollTo(0, 0) are not working on mobile in Chrome
[英]Window.scroll / scrollTo method to work in position:fixed div rather then document.body
我有一個position:fixed
div與e.scrollIntoView
overflow-y:scroll
因為e.scrollIntoView
方法工作正常, window.scroll
和scrollto
方法未應用於此固定div,但嘗試滾動document.body
在這種情況下有什么解決方法嗎? 是否可以使window.scroll
或window.scrollTo
方法在固定的div容器中工作。
期待聽到您的感謝。
像這樣的事情呢:
function scrollto(elemSelector) {
var $wrapper = document.querySelector('.fixed-wrapper'),
$el = document.querySelector(elemSelector);
$wrapper.scrollTop = $el.offsetTop;
}
在此處查看演示: https : //codepen.io/anon/pen/mXJMrx
那是你要的嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.