html - 将文本放置在带有覆盖层和图像的 div 的中心底部

标签 html css twitter-bootstrap-3

我试图将一些文本放置在包含覆盖层和图像的 div 的中心底部。

但是我怎样才能实现这个目标呢?

HTML 代码:

<div class="container">
    <div class="row team-images">
        <div class="col-sm-3">
            <div class="team-item">
                <div class="team-image-overlay"></div>
                <img src="http://placehold.it/400x400" class="img-responsive" alt="" />
            </div>
        </div>
        <div class="col-sm-3">
            <div class="team-item">
                <div class="team-image-overlay"></div>
                <img src="http://placehold.it/400x400" class="img-responsive" alt="" />
            </div>
        </div>
        <div class="col-sm-3">
            <div class="team-item">
                <div class="team-image-overlay"></div>
                <img src="http://placehold.it/400x400" class="img-responsive" alt="" />
            </div>
        </div>
    </div>
</div>

CSS 代码:

.team-images .team-item {
    position: relative;
}
.team-images img {
    width: 100%;
    height: 100%;
    margin: 0 0 15px;
}
.team-images .team-image-overlay {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(41, 128, 185, 0.4);
    color: #fff;
    -webkit-transition: all ease .5s;
    -moz-transition: all ease .5s;
    transition: all ease .5s;
}
.team-images .team-image-overlay:hover {
    background: rgba(24, 188, 156, 0);
}

这是迄今为止创建的内容的完整示例:https://jsfiddle.net/prp794Lb/1/

最佳答案

这个怎么样?

<div class="container">
<div class="row team-images">
    <div class="col-sm-3">
        <div class="team-item">
            <div class="team-text">Text here</div>
            <div class="team-image-overlay"></div>
            <img src="http://placehold.it/400x400" class="img-responsive" alt="" />
        </div>
    </div>
    <div class="col-sm-3">
        <div class="team-item">
            <div class="team-text">Lots and lots and lots and lots and lots of text here</div>
            <div class="team-image-overlay"></div>
            <img src="http://placehold.it/400x400" class="img-responsive" alt="" />
        </div>
    </div>
    <div class="col-sm-3">
        <div class="team-item">
            <div class="team-text">Text here</div>
            <div class="team-image-overlay"></div>
            <img src="http://placehold.it/400x400" class="img-responsive" alt="" />
        </div>
    </div>
</div>

    /* Latest compiled and minified CSS included as External Resource*/

/* Optional theme */
 @import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
 body {
    margin: 10px;
}
.team-images .team-item {
    position: relative;
}
.team-images img {
    width: 100%;
    height: 100%;
    margin: 0 0 15px;
}
.team-images .team-image-overlay {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(41, 128, 185, 0.4);
    color: #fff;
    -webkit-transition: all ease .5s;
    -moz-transition: all ease .5s;
    transition: all ease .5s;
}
.team-images .team-image-overlay:hover {
    background: rgba(24, 188, 156, 0);
}
.team-item .team-text {
    position: absolute;
    width: 100%;
    bottom: 0;
    text-align: center;
}

https://jsfiddle.net/wL5Lf5se/3/

关于html - 将文本放置在带有覆盖层和图像的 div 的中心底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29878233/

相关文章:

javascript - jQuery 检测 Bootstrap 3 状态

javascript - 当我在javascript中按下新字符时如何替换最后一个特殊字符

javascript - AngularJS 触发功能单击 anchor 链接

jquery - 用于联系表格的选项卡 Accordion 的 CSS 或 Jquery

html - 删除 Blogger 自定义模板中的侧边栏线

javascript - 有没有办法排除规则而不影响我的 jQuery?

javascript - 仅在必要时水平滚动

javascript - 使用 <a> 开始动画到动画所在的部分?

jquery - 在网页中更快地加载图像

html - Twitter Bootstrap - 为特定设备/用户代理强制响应/布局宽度