Learn how to place text blocks over an image.
What a beautiful sunrise
What a beautiful sunrise
<div class="container">
<img src="nature.jpg" alt="Norway" style="width:100%;">
<div class="text-block">
<h4>Nature</h4>
<p>What a beautiful sunrise</p>
</div>
</div>
/* Container holding the image and the text */
.container {
position: relative;
}
/* Bottom right text */
.text-block {
position: absolute;
bottom: 20px;
right: 20px;
background-color: black;
color: white;
padding-left: 20px;
padding-right: 20px;
}
Try it Yourself »
To learn more about how to style images, read our CSS Images tutorial.
To learn more about CSS positoning, read our CSS Position tutorial.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!