我是JqueryMobile的新手。我有一个包含3 * 3网格图像的屏幕。我需要将它们对齐在页面的中心,除了1px之外,它们之间不应该有任何空格。每个单元格应该适合图像而不拉伸。所有图像的宽度均为100像素,高度为150像素。请帮帮我。
<div class="ui-grid-b">
<div class="ui-block-a">
<div class="ui-bar">
<a href="xxx.htm">
<img alt="alt..." src="bigmiracle.png" />
</a>
</div>
</div>
<div class="ui-block-b">
<div class="ui-bar">
<a href="xxx.htm">
<img alt="alt..." src="bigmiracle.png" />
</a>
</div>
</div>
<div class="ui-block-c">
<div class="ui-bar">
<a href="xxx.htm">
<img alt="alt..." src="bigmiracle.png" />
</a>
</div>
</div>
<div class="ui-block-a">
<div class="ui-bar">
<a href="xxx.htm">
<img alt="alt..." src="bigmiracle.png" />
</a>
</div>
</div>
<div class="ui-block-b">
<div class="ui-bar">
<a href="xxx.htm">
<img alt="alt..." src="bigmiracle.png" />
</a>
</div>
</div>
<div class="ui-block-c">
<div class="ui-bar">
<a href="xxx.htm">
<img alt="alt..." src="bigmiracle.png" />
</a>
</div>
</div>
这是屏幕截图。
答案 0 :(得分:4)
首先,使用jQuery Mobile网格无法做到这一点。该网格是响应和伸展。创建我们自己的包含所需图像的网格是更好的解决方案。
我只是不明白你打算使用:
<div class="ui-bar">
或包含它是错误的。没有它,我做了这个例子。如果您希望网格完全包裹图像,则无需使用。
以下是一个有效的例子:http://jsfiddle.net/Gajotres/VUWAA/
HTML:
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<div data-role="page" id="index">
<div data-theme="b" data-role="header">
<h1>Index page</h1>
</div>
<div data-role="content">
<div class="grid-container">
<div class="grid-row">
<a href="index.htm">
<img alt="alt..." src="http://th01.deviantart.net/fs12/150/i/2006/287/3/4/puppy_pug_3_by_WeiTat.jpg" />
</a>
<a href="index.htm">
<img alt="alt..." src="http://th01.deviantart.net/fs12/150/i/2006/287/3/4/puppy_pug_3_by_WeiTat.jpg" />
</a>
<a href="index.htm">
<img alt="alt..." src="http://th01.deviantart.net/fs12/150/i/2006/287/3/4/puppy_pug_3_by_WeiTat.jpg" />
</a>
</div>
<div class="grid-row">
<a href="index.htm">
<img alt="alt..." src="http://th01.deviantart.net/fs12/150/i/2006/287/3/4/puppy_pug_3_by_WeiTat.jpg" />
</a>
<a href="index.htm">
<img alt="alt..." src="http://th01.deviantart.net/fs12/150/i/2006/287/3/4/puppy_pug_3_by_WeiTat.jpg" />
</a>
<a href="index.htm">
<img alt="alt..." src="http://th01.deviantart.net/fs12/150/i/2006/287/3/4/puppy_pug_3_by_WeiTat.jpg" />
</a>
</div>
<div class="grid-row">
<a href="index.htm">
<img alt="alt..." src="http://th01.deviantart.net/fs12/150/i/2006/287/3/4/puppy_pug_3_by_WeiTat.jpg" />
</a>
<a href="index.htm">
<img alt="alt..." src="http://th01.deviantart.net/fs12/150/i/2006/287/3/4/puppy_pug_3_by_WeiTat.jpg" />
</a>
<a href="index.htm">
<img alt="alt..." src="http://th01.deviantart.net/fs12/150/i/2006/287/3/4/puppy_pug_3_by_WeiTat.jpg" />
</a>
</div>
</div>
</div>
</div>
</body>
</html>
CSS:
.grid-container {
margin-left: auto;
margin-right: auto;
width: 302px;
height: 452px;
}
.grid-row {
width: 302px;
height: 150px;
margin-bottom: 1px;
}
.grid-row_last-child {
margin-bottom: 0px;
}
.grid-row a {
position:relative;
float: left;
display: block;
width: 100px;
height: 150px;
margin-right: 1px;
}
.grid-row a:last-child {
margin-right: 0px;
}