繁体   English   中英

图像底部的浮动文本

[英]Floating text on bottom of image

我正在尝试创建类似这样的东西: 我正在尝试创造的 但是我只是做错了。 到目前为止,这是我所拥有的: jsfiddle
HTML:

<div class="review">
    <div class="review-head">
        <h2> Batman Arkham Knight Review </h2>
    </div>
</div>

CSS:

.review-head {
    height: 20em;
    background: url(http://www.flickeringmyth.com/wp-content/uploads/2014/03/Arkham-Knight2.jpg) no-repeat center center;
    background-size: cover;
}
h2 {
    color: white;
    vertical-align: center;
}

我在这里想念什么?
不管是否重要,我都试图将图像放入Bootstrap面板中。 感谢帮助!

给您的review-head元素一个position 这将允许您在其中放置h2

 .review-head { height: 20em; background: url(http://www.flickeringmyth.com/wp-content/uploads/2014/03/Arkham-Knight2.jpg) no-repeat center center; background-size: cover; position: relative; } h2 { color: white; vertical-align: center; position: absolute; bottom: 20px; left: 20px; } 
 <div class="review"> <div class="review-head"> <h2> Batman Arkham Knight Review </h2> </div> </div> 

h2更改为此:

h2 {
    color: white;
    position:absolute;
    bottom: 0px;
}

我的建议是使用具有id或class的div元素来实现这一点。 例如<div class="imgTextFooter" ></div>并在此处应用您想要的样式:)

忘记添加,您必须添加position:relative对于.review-head

小提琴

position: relative;

到父级

position: absolute; 
bottom: 0;

到h2。

暂无
暂无

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

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