Html iPad 上 div 垂直滚动条的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3890400/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 04:47:18  来源:igfitidea点击:

Problems with div vertical scrollbars on iPad

cssipadhtmlscroll

提问by Martin

When a user perform a search on my website I want to show the result in a small div with vertical scrollbars instead of that the user need to scroll the full page. That works perfect in all browsers BUT I get problems on the iPad. I can see that the search result doesn't fit into the div but no scroll bar is showing up on the iPad. Also when I try to scroll inside the div the full page is scrolled instead. Is there a solution to get this working?

当用户在我的网站上执行搜索时,我想在带有垂直滚动条的小 div 中显示结果,而不是用户需要滚动整个页面。这在所有浏览器中都很完美,但我在 iPad 上遇到了问题。我可以看到搜索结果不适合 div,但 iPad 上没有显示滚动条。此外,当我尝试在 div 内滚动时,会滚动整个页面。有没有办法让这个工作?

HTML AND CSS:

HTML 和 CSS:

<div class="searchResult">
    //Here I show the search result
</div>

div.searchResult
{
    height: 540px;
    overflow: -moz-scrollbars-vertical;
    overflow-y: scroll;
}

回答by tahdhaze09

I believe the answer is that you cannot scroll unless you use the two-finger methods. However if you look at the last link, there is a workaround.

我相信答案是除非您使用两指方法,否则您无法滚动。但是,如果您查看最后一个链接,则有一种解决方法。

Issues:
CSS Overflow property not working in iPad
http://www.webmanwalking.org/library/experiments/dsp_frames_outer_document.html

问题:
CSS 溢出属性在 iPad 中不起作用
http://www.webmanwalking.org/library/experiments/dsp_frames_outer_document.html

Workaround:
http://cubiq.org/scrolling-div-on-iphone-ipod-touch

解决方法:http:
//cubiq.org/scrolling-div-on-iphone-ipod-touch

回答by Bennett McElwee

iScrollis the jQuery plugin that tahdhaze09 mentioned. And to be more specific:

iScroll是 tahdhaze09 提到的 jQuery 插件。更具体地说:

iScroll is evolving and adding many new features to the basic scrolling functionality. If all you need is the plain old scroller for mobile webkit, you should really use iscroll-lite.jsinstead.

iScroll 不断发展,并为基本滚动功能添加了许多新功能。如果您只需要用于移动 webkit 的普通旧滚动条,那么您真的应该iscroll-lite.js改用它。

iscroll-lite.jsis part of the iScroll package. It looks as if it will solve the one-finger scroll problem quite nicely.

iscroll-lite.js是 iScroll 包的一部分。看起来它可以很好地解决单指滚动问题。

回答by user697021

For some odd reason changing the div to a span works on an iPad.

出于某种奇怪的原因,将 div 更改为跨度适用于 iPad。