scrollIntoView()方法导致IE10中出现问题 [英] scrollIntoView() method causing issues in IE10

查看:812
本文介绍了scrollIntoView()方法导致IE10中出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在IE10中使用此方法时,如果元素位于中间,则会导致整个页面向左移位。并且如果控件(滚动)在中间,它将被带到窗口的左侧,元素之前的内容是
不可见。

When I use this method in IE10, it is causing entire page to shift left side, if the element is in middle. And also if the control(which is scrolled) is in the middle, it is brought to the left side of the window, and the content before the element is not visible.

推荐答案

这正是滚动到视图命令的行为方式。

That's exactly how scroll-into-view command should behave.

如果您的文档正文比窗口页面视图宽,则您要调用的元素进入视图,必须向右滚动到可用滚动窗口的左边缘,与它一样,并且必须为可用的垂直滚动
位置做。

If your document body is wider than the window page view, the element you are calling into view, will have to scroll right to the left edge of the window of the available scroll, same as it does and has to do for the available vertical scroll position.

如果你想让它滚动到视图中而不是隐藏目标元素左侧的元素,你需要将命令附加到它包含两个元素的父元素,并且是与文件正文的宽度相同。

If you want it to scroll into view but not hide elements that are on the left side of the target element, you need to attach the command to its parent which wraps both elements and is of the same width as the document body.


这篇关于scrollIntoView()方法导致IE10中出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆