以下 html 和 css 格式排列我的图像,以便通过浮动每行有九个。然而,每一行的末尾都有一个很大的间隙(但可能不足以容纳另一个图像,因此新行开始):
HTML:
<div id = "body">
<div class="img">
<a href="">
<img src="" width="110" height="90">
</a>
<div class="desc"></div>
</div>
<div class="img">
<a href="">
<img src="" width="110" height="90">
</a>
<div class="desc"></div>
</div>
</div>
//This is repeated many times so that there are 4 rows of nine images
CSS:
div.img
{
margin:2px;
border: 2px solid #000000;
height:auto;
width:auto;
float:left;
text-align:center;
}
div.img img
{
display:inline;
margin:8px;
}
div.desc
{
text-align:center;
font-weight:normal;
width:120px;
margin:5px;
}
我的第一个问题是我如何“移动”每一行的第一张图像,以便画廊在屏幕上是对称的。我的第二个问题涉及如何确保这种形式(9x4)在每个浏览器(每个屏幕宽度)中都是相同的?
目前我一直在使用一个固定的容器(以像素为单位)来填充我自己的屏幕。提前谢谢了。