【发布时间】:2012-08-22 11:54:07
【问题描述】:
在我的 phonegap 应用程序中,我想实现水平滚动视图。我的html代码
<div id="songsListPage" data-role="page">
<div id="alphabets" >
<a href="#" >#</a>
<a href="#" >A</a>
<a href="#" >B</a>
<a href="#" >C</a>
<a href="#" >D</a>
<a href="#" >E</a>
<a href="#" >F</a>
<a href="#" >G</a>
<a href="#" >H</a>
<a href="#" >I</a>
<a href="#" >J</a>
<a href="#" >K</a>
<a href="#" >L</a>
<a href="#" >M</a>
</div>
<div id="songs_list" data-role="content"> <!-- this should not scroll, but it is and showing white background on right side -->
<ul id="songsList" data-role="listview" data-theme="a"></ul> <!-- list is populated dynamically -->
<p>This is songs page</p>
<a href="player.html" id="playerBtn" data-role="button" class="ui-btn-active" ></a>
</div>
</div>
我的 CSS
#alphabets {
background:#000000;
display: block;
padding: 5px;
clear: both;
height: 30px;
margin-bottom: 22px;
padding-left: 5px;
padding-right: 5px;
padding-top: 5px;
width: 200%;
overflow-x: auto;
}
#alphabets a{ color: #ffffff; margin-left: 5px}
通过给出“width: 200%”和“overflow-x: auto”,我得到了水平滚动,但问题是我的屏幕的其余部分也在水平滚动,所以有什么办法可以做到这一点吗?
【问题讨论】:
-
如此臃肿的代码。实际上,我发现表比 LI 和 DIV 列表更有效。我也为 jSFiddle 编辑了这个。 jsfiddle.net/CXAWE
-
感谢@TheBlackBenzKid 它起作用了,我将 ui 和 div 分别更改为 tr 和 table,并将宽度更改为 100%。我忘记提到溢出属性在桌面浏览器中工作正常,但它在手机(android)浏览器中不起作用,但它正在使用表格标签。再次感谢
-
我添加了我的代码作为答案。希望你能删除你的并接受我的?