scrollTop (IIRC) is where in the document the top of the page is scrolled to. scrollTo scrolls the page so that the top of the page is where you specify.
这里需要的是一些 Javascript 操纵的样式。假设你想让 div 离开屏幕,从右边滚动进来,你需要将 div 的左边属性设置为页面的宽度,然后每隔几秒钟减少一个设置值,直到它到达你想要的位置。
This should point you in the right direction.
附加说明: 对不起,我以为您需要一个单独的 div 来从某个地方“弹出”(有点像这个网站有时候做的那样) ,而不是将整个页面移动到某个部分。正确使用锚点可以达到这种效果。
$('a[href=#target]').
click(function(){
var target = $('a[name=target]');
if (target.length)
{
var top = target.offset().top;
$('html,body').animate({scrollTop: top}, 1000);
return false;
}
});
You can use Element.scrollIntoView() method as was mentioned above. If you leave it with no parameters inside you will have an 瞬间丑陋的卷轴. To prevent that you can add this parameter - behavior:"smooth".