css - 在带有深色边框的图像底部添加文本

标签 css html web twitter-bootstrap-3

我想在图像末尾添加深色边框并在其上写文字。我附上了我想要的屏幕截图。 有谁知道如何解决这个问题? enter image description here

最佳答案

我猜是这样的吗?

您应该阅读元素的 position CSS。 Position absolute and relative

Fiddle for you

<div class="container">
    <img src="http://placehold.it/200x150" alt="" /> 
    <span>Here's your text</span>
</div>

* {
    box-sizing: border-box;
}
.container {
    position: relative;
}
.container span {
    position: absolute;
    bottom: 0px;
    background-color: red;
    width: 200px;
    display: block;
    padding: 10px 15px;
    text-align: center;
    text-transform: uppercase;
    color: #fff;
}

关于css - 在带有深色边框的图像底部添加文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30712715/

相关文章:

javascript - 满足的状态

api - 使用JS加载和播放音频时遇到问题

html - 如何下载单个网页以供离线查看?

html - 使用 Selenium Webdriver,如何找到与 div 关联的所有类?

html - float 元素在存在最大宽度时中断到新页面

html - CSS 响应式边距顶部

php - 后台执行PHP MYSQL

jquery - 在圆圈内居中加/减切换元素

html - Firefox 中的字形图标是像素化的

jquery - 试图让 css 中的最后一个 child ,但它不起作用