如何防止在启动Web应用程序时显示滚动条

时间:2022-02-23 00:26:13

I'm developing a web application for Firefox OS, i'm using HTML 5 and jQuery Mobile for this app,

我正在为Firefox OS开发一个Web应用程序,我正在为这个应用程序使用HTML 5和jQuery Mobile,

I'm using different pages and give the user the ability to swipe between pages

我正在使用不同的页面,并使用户能够在页面之间滑动

<div data-role="page" id="p1"></div>

$.mobile.changePage('#p'+i, {
    transition: "slide"
});

some pages need scrolling, some don't. When I swipe from one page to another, the appearance of a scrollbar moves the page a few pixels to the side. and it's affecting the swipe as well. Is there any way to avoid this without explicitly showing the scrollbars on each page?

有些页面需要滚动,有些则不需要。当我从一个页面滑动到另一个页面时,滚动条的外观会将页面移动几个像素到一侧。它也影响了滑动。如果没有在每个页面上明确显示滚动条,有没有办法避免这种情况?

I tried to add scroll to all the pages but still have the same problem :

我试图向所有页面添加滚动但仍然有同样的问题:

html {
    overflow-y: scroll;
}

It works when disable scroll completely, but I want always to have the scroll ability without showing the scroll bar, or showing it after page load.

它完全禁用滚动时有效,但我希望始终具有滚动功能而不显示滚动条,或在页面加载后显示它。

1 个解决方案

#1


I want always to have the scroll ability without showing the scroll bar, or showing it after page load.

我希望始终拥有滚动功能而不显示滚动条,或在页面加载后显示它。

You won't be able to have scroll functionality if the scroll bar is not visible. You will probably have to use some external scripts such as iScroll.js or similar.

如果滚动条不可见,您将无法使用滚动功能。您可能必须使用一些外部脚本,如iScroll.js或类似的。

The scroll bar is created on document ready and updated on document load. Delaying its appearance to on loadwon't make any improvement to your problem as far as I understood.

滚动条在文档就绪时创建,并在文档加载时更新。根据我的理解,将其外观延迟到负载不会对您的问题做任何改进。

#1


I want always to have the scroll ability without showing the scroll bar, or showing it after page load.

我希望始终拥有滚动功能而不显示滚动条,或在页面加载后显示它。

You won't be able to have scroll functionality if the scroll bar is not visible. You will probably have to use some external scripts such as iScroll.js or similar.

如果滚动条不可见,您将无法使用滚动功能。您可能必须使用一些外部脚本,如iScroll.js或类似的。

The scroll bar is created on document ready and updated on document load. Delaying its appearance to on loadwon't make any improvement to your problem as far as I understood.

滚动条在文档就绪时创建,并在文档加载时更新。根据我的理解,将其外观延迟到负载不会对您的问题做任何改进。