对齐图片中心,响应式 div 的底部

Align an image center, bottom of a responsive div

<div id="banner" class="cf">
        <div class="banner container">
            <hr/>
            <p class="banner-text">
            Some text here
            <span class="sub-bt">That's it.</span>
            </p>
            <a href="#" rel="nofollow" class="learn-btn">Learn More</a>

            <img src="<?php echo get_template_directory_uri(); ?>/library/images/responsive_ex.png" class="res-ex">
        </div>
    </div>

这是到目前为止问题的代码。我需要将 class of "res-ex" 的图像定位到 div class of "banner".

的底部

我已经尝试了多个 table-cell 和位置代码,但似乎无法正常工作。

设计也是响应式的。

您可以使用定位将图像放在 div 的底部,然后使用 CSS 变换将其居中。

.wrap {
    height: 400px;
    position: relative;
    background: #f09d09;
}

.wrap img{
    display: block;
    max-width: 100%;
    position: absolute;
    bottom:0;
    left:50%;
    transform:translateX(-50%);
    
}
<div class="wrap">
    <img src="http://lorempixel.com/400/200/" alt=""/>
</div>

JSFiddle Demo

代码如下:

.res-ex {
    position:absolute;
    min-width:100px;
    min-height:100px;
    bottom:0;
    display:inline-block;
}
.banner.container {
    position:relative;
}

您需要为图像设置 position:absolutedisplay:inline-block(或 display:block),并为其容器设置 position:relative。 然后你为图像设置bottom:0