在固定高度 div 中垂直对齐图像
我到处搜索知识库,但似乎没有任何结果。
我在下面附上了我正在处理的内容的屏幕截图和代码,但我需要做的是根据最高图像创建的 div 的高度垂直对齐图像。
所以,有几件事。容器 .one-edition 的固定高度由最高图像尺寸决定 - 我可以用 JS 做到这一点吗?
然后,一旦确定了高度,图像就会在中间垂直对齐。
希望这是有道理的。
<div class="grid_3 one-edition">
<a href="product-1.php"><img src="images/editions/1_Right_To_Buy_295.jpg"></a>
<div class="editions-info-text">
<p>Right To Buy</p>
<p>C-type Print</p>
</div>
</div>
<div class="grid_3 one-edition">
<a href="product-1.php"><img src="images/editions/2_Scorer_295.jpg"></a>
<div class="editions-info-text">
<p>Hyperbolic Paraboloid Roof</p>
<p>Offset Print</p>
</div>
</div>
<div class="grid_3 one-edition">
<a href="product-1.php"><img src="images/editions/3_PL16_295.jpg"></a>
<div class="editions-info-text">
<p>132Kv PL16</p>
<p>Offset Print</p>
</div>
</div>
<div class="grid_3 one-edition">
<a href="product-1.php"><img src="images/editions/4_What_We_buy_295.jpg"></a>
<div class="editions-info-text">
<p>What We Buy</p>
<p>Publication</p>
</div>
</div>
I have searched the knowledge base high and low, but nothing seems to give me a result.
I have attached a screenshot and code of the content I'm working on below, but what I'm needing to do is vertically align the images based on the height of the div created by the tallest image.
So, a few things. The fixed height of the container .one-edition is determined by the tallest image size - can I do this with JS?
Then, once the height is determined, the images are aligned vertically in the middle.
Hope this makes sense.
<div class="grid_3 one-edition">
<a href="product-1.php"><img src="images/editions/1_Right_To_Buy_295.jpg"></a>
<div class="editions-info-text">
<p>Right To Buy</p>
<p>C-type Print</p>
</div>
</div>
<div class="grid_3 one-edition">
<a href="product-1.php"><img src="images/editions/2_Scorer_295.jpg"></a>
<div class="editions-info-text">
<p>Hyperbolic Paraboloid Roof</p>
<p>Offset Print</p>
</div>
</div>
<div class="grid_3 one-edition">
<a href="product-1.php"><img src="images/editions/3_PL16_295.jpg"></a>
<div class="editions-info-text">
<p>132Kv PL16</p>
<p>Offset Print</p>
</div>
</div>
<div class="grid_3 one-edition">
<a href="product-1.php"><img src="images/editions/4_What_We_buy_295.jpg"></a>
<div class="editions-info-text">
<p>What We Buy</p>
<p>Publication</p>
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经看到很多答案,但我仍然发布这个,因为我花了时间使用 placekittens..
http://jsfiddle .net/7ybzp/6/
基本上,我使用了
vertical-align: middle
。不过我使用了inline-block
。I see many answers already but I'm still posting this, because I spent time using placekittens..
http://jsfiddle.net/7ybzp/6/
Basically, I used
vertical-align: middle
. I usedinline-block
though.