【发布时间】:2017-07-30 01:56:44
【问题描述】:
代码如下:
<div class="wrapper">
<div id="squares">
<a href="yourlinkhere1.php"><img src="images/galleryimage1.jpg"></a>
<h5>IMG_114</h5>
</div>
<div id="squares">
<a href="yourlinkhere2.php"><img src="images/galleryimage2.jpg"></a>
<h5>IMG_115</h5>
</div>
</div>
CSS 看起来像:
.wrapper {
background: #ff0000;
text-align: center;
}
#squares {
background: #00ff00;
display: inline-block;
vertical-align: top;
width: 300px;
}
#squares img {
max-height: 200px;
width: auto;
}
#squares h5 {
margin: 20px 0;
}
我喜欢它的结果,但我希望IMG_117 在IMG_114 下对齐,同时保持绿色区域居中并且 div 中的内容居中...不知道如何让该 div 不左对齐不居中其他东西。
我在想这可能是对我的 css 或一些 jQuery 的快速调整,以便在 IMG_117 行中再添加两列。我看到的问题是这是动态内容,我并不总是知道最后一行有多少……可能是一、二或三,如果有一些 jQuery,它需要检查并查看有多少项目在行中,然后添加缺少的列。
我不确定哪种方法最简单,或者是否有更好的解决方案...有没有人有任何想法或谁能指出我正确的方向?
谢谢,
乔什
【问题讨论】:
标签: jquery css alignment gallery