在某个滚动点开始页面 [英] Starting a page at a certain scroll point

查看:23
本文介绍了在某个滚动点开始页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法(使用 CSS3、JS 或介于两者之间的任何方法)让页面从向下滚动的某个点开始?

Is there a way (with CSS3, JS, or anything in between) to get a page to start at a certain point scrolled down?

我希望我的页面加载时最初不显示标题(这意味着它位于用户的实际视口上方).

I'd like for my page to load without the header initially displaying on load (meaning it's above the actual viewport of the user).

有没有简单/容易的方法来解决这个问题?

Is there a simple/easy way to go about this?

推荐答案

您可以使用标准的 javascript:window.scroll(x, y).

You can use standard javascript: window.scroll(x, y).

考虑到您将在 onload 处执行此操作,这应该很有效,即窗口应从 (0, 0) 开始.玩转 (x, y) 直到你的标题达到你满意的位置.当然,您需要在标题移动时随时更改它.

This should work pretty well considering that you'll be doing this at onload, i.e. the window should begin at (0, 0). Play around with (x, y) until you get your header to the position that you're happy with. Naturally you'll need to change it anytime the header moves.

示例:

<body onLoad="window.scroll(0, 150)">

这篇关于在某个滚动点开始页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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