【发布时间】:2014-12-12 15:07:37
【问题描述】:
我是 JQuery 移动版的新手。我正在为当地一家餐馆制作移动网络。我想在菜单中的每张图片上加上标题,幸运的是我偶然发现了 Mosaic JQuery 插件并且能够使用它。添加标题成功,现在的问题是图像没有对齐到Android手机浏览器的中心。
上图显示图像未居中对齐,左侧有边距(蓝色),现在右侧有边距(红色)。
到目前为止,这是我的代码:
(HTML)
<div data-role="main" class="ui-content" align="center" >
<div class="hh">
<h2><br>Delicious Meals to taste!</h2>
</div>
<div class="mosaic-block bar2">
<a style="left: 0px; bottom: -50px;" href="maindish.html" target="_blank" class="mosaic-overlay">
<div class="details">
<h4>Delicious Main Dishes inside</h4><br>
<h6>UCLM Restaurant (photo credit: Dan Deroches)</h6>
</div>
</a>
<a href="maindish.html">
<div style="display: block;" class="mosaic-backdrop"><img src="images/maindish/Rosemary-Chicken-Kabob.jpg"></div>
</a>
</div>
<div class="mosaic-block bar2">
<a style="display: inline; left: 0px; bottom: -50px;" href="maindish.html" target="_blank" class="mosaic-overlay">
<div class="details">
<h4>Delicious Main Dishes inside</h4><br>
<p>UCLM Restaurant (photo credit: Dan Deroches)</p>
</div>
</a>
<a href="maindish.html">
<div style="display: block;" class="mosaic-backdrop"><img src="images/maindish/Rosemary-Chicken-Kabob.jpg"></div>
</a>
</div>
</div><!--content-->
(CSS)
.mosaic-block {
float:left;
position:relative;
left:50%;
overflow:hidden;
width:400px;
height:250px;
margin:0px;
background:#111 url(../img/progress.gif) no-repeat center center;
border:1px solid #fff;
-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.5);
}
我在每个 div 上尝试了 align-center 但没有运气。 有什么想法吗?
【问题讨论】:
-
尝试将 (margin: auto;) 添加到 img 标签,看看是否有帮助
-
@Tasos - 不,什么都没有发生
标签: android jquery html css jquery-mobile