如何在Android中获取可滚动的div
我添加了一个包含大量数据的 div
,它在 PC 和 Blackberry 上运行良好,但在 Android 上不起作用:数据检索没有问题,但 < code>div 不可滚动。
这是 HTML 代码:
<div id="scroll">
<div runat="server" ID="view"></div>
</div>
和 CSS:
#view
{
position: absolute;
top: 15%;
left: 0.9%;
width: 98.3%;
height: 75%;
font-family: Calibri;
font-size: 0.5em;
white-space: pre-wrap;
border: 1px solid black;
overflow: auto;
padding: 0.2em;
}
有什么问题吗?
i added a div
with a lot of data in it, and it works fine on a PC and on the Blackberry, but it doesn't work on Android: The data is retrieved with no problems but the div
isn't scrollable.
Here is the HTML code:
<div id="scroll">
<div runat="server" ID="view"></div>
</div>
And the CSS:
#view
{
position: absolute;
top: 15%;
left: 0.9%;
width: 98.3%;
height: 75%;
font-family: Calibri;
font-size: 0.5em;
white-space: pre-wrap;
border: 1px solid black;
overflow: auto;
padding: 0.2em;
}
What is the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试在本机 Android 应用程序上执行此操作,则必须实现 ScrollView:
http://developer.android.com/reference/android/widget/ScrollView.html
If you're trying to do this on a native android application, you're going to have to implement a ScrollView:
http://developer.android.com/reference/android/widget/ScrollView.html
我找到了一个创造性的解决方法(适用于 Android (2.3.5 Gingerbread) 和适用于 Android 的 Firefox 浏览器)。
我在第一个网站上没有报告问题,但在第二个网站上却遇到了问题。在这里找到这个答案后,我记得旧网站可以工作,所以我检查了我在那里做了什么。将旧站点复制到新站点我能够解决我的问题...
这适用于 Android/Firefox 浏览器,但不会在屏幕上放置滚动条指示器(但触摸拖动会将内容向下滚动。
对我有用的是双重标签...嵌入代码以在第二个标签中滚动。
div style="width: 100%; height: 100%;背景颜色:#fdc4f6; 边框:实心 1px #000;">
div style="overflow:scroll; height:350px; ; padding: 1em 4em 0 4em;"> [如果文本在 Android 上溢出 div,内容将滚动]
然后关闭 DIV 标签,现在第二个内容
可能不是最漂亮的代码或方法使用,但它为我完成了工作(尽管我还没有在 iOS 设备上进行过测试)
。
-磅-
I found a creative work-around (that works on Android (2.3.5 Gingerbread) and Firefox browser for Android).
I didn't have the problem reported here on the first site I did but had issues on the second. After finding this answers here I remembered the old site worked so I checked what I did there. Copying over old to new site I was able to fix my problem...
This works on Android/Firefox browser but does not put a scroll bar indicator on screen (but touch-drag scrolls the content down the .
What WORKED for me is dual Tags... EMBED code to scroll in a second tag.
<div style="width: 100%; height: 100%; background-color:#fdc4f6; border: solid 1px #000;">
<div style="overflow:scroll; height:350px; text-align:left; padding: 1em 4em 0 4em;"> [Content will scroll if text overflows div on Android now]
then close DIV tags now the content in the second
may not be the prettiest code or method to use, but it got the job done for me (although I haven't tested in iOS devices).
For what it's worth...
-LB-