11

私のウェブページのモバイルビューでは、縦方向と横方向にスクロールできますが、これは常に左上隅から始まります。ここで、window.scrollTo または同等のものを使用して、ビューポートをカスタム位置に設定したいと考えています。window.scroll は、デスクトップ ブラウザーで動作するようです。

どうすればそれを解決できますか?

4

2 に答える 2

5

私はついにそれを働かせました。

さらにsetTimeout関数を使用する必要がありました

setTimeout(window.scrollTo(x,y),100);
于 2012-08-08T12:56:52.543 に答える
1

As I said in my comment, this works if your content is large enough. This means larger than the viewport. Without knowing specifics, did you look into setting the viewport meta tag?

<meta name="viewport" content="width=device-width, initial-scale=1.0">

Now, if your content div or image or whatever exceeds the size of the viewport width (320 dips on iPhone) you can scroll on the x axis. The same is true for the y axis with different values though.

于 2012-08-07T12:05:13.537 に答える