【发布时间】:2012-03-18 23:52:04
【问题描述】:
我正在使用 jQuery mobile,我试图将一些图像图标置于列表的中心。我遇到的问题是图像不在列表项中垂直居中。
由于到目前为止我还不是 CSS 专家,因此有人能指出我正确的方向吗?我知道我可以使用表格来获取它们,但我不想这样做。谢谢。
哦,我在下面的代码中使用了 EJS。请看截图:
这是我的代码:
<li data-icon="false">
<a href="#">
<img src="images/img_trans.gif" class='largePlatform platform_<%= releases[i].platform_abbr %>_large' width='30' height='30' style="position:absolute; top:25%; left:10px"/>
<h2 style="position:absolute; top:25%; left:50px"><%= releases[i].platform_abbr %></h2>
<div data-role="controlgroup" data-type="horizontal" style="float:right" >
<% if (purchaseText != "") { %>
<img src="images/game_detail/<%= releases[i].purchase_button_icon %>-purchase.png" width="35" height="35" onclick="window.open('<%= releases[i].purchase_button_url %>');" alt="<%= purchaseText %>" style="position:relative; top:10px;"/>
<% } %>
<div data-role="button" data-icon="reminder" data-theme="<%= buttonTheme %>" onclick="<%= buttonAction %>(<%= releases[i].id %>)">
<%= buttonText %>
</div>
</div>
</a>
</li>
【问题讨论】:
-
答案将取决于图像相对于 li 中的 other 内容的布局方式。你能详细说明一下吗?
-
确定。所以我的 li 元素有 3 个并排设置的图像,它们都在顶部垂直对齐。就像 [img some text img img]
-
对不起——你能澄清一下你所说的“......在顶部垂直对齐”是什么意思。
-
还有:你的li会有固定的高度吗?
-
@Faust:请看我上面添加的图片。如您所见,图像似乎彼此不对齐。我只希望它们对齐。是的,看起来 li 的高度是固定的。
标签: html css jquery-mobile ejs