简体   繁体   English

垂直对齐固定高度div中的图像

[英]Vertically aligning images in a fixed height 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. 我附上了我正在处理的内容的截图和代码,但我需要做的是根据最高图像创建的div的高度垂直对齐图像。

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? 容器.one-edition的固定高度由最高的图像大小决定 - 我可以用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>

在此输入图像描述

I see many answers already but I'm still posting this, because I spent time using placekittens.. 我已经看到很多答案,但我仍然发布这个,因为我花时间使用placekittens ..

http://jsfiddle.net/7ybzp/6/ http://jsfiddle.net/7ybzp/6/

Basically, I used vertical-align: middle . 基本上,我使用vertical-align: middle I used inline-block though. 我虽然使用了inline-block

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM