Gewusst wie: Textblöcke über Bild
Erfahren Sie, wie Sie Textblöcke über einem Bild platzieren.
Bildtextblöcke
So platzieren Sie Textblöcke im Bild
Schritt 1) HTML hinzufügen:
Beispiel
<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>
Schritt 2) CSS hinzufügen:
Beispiel
/* 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;
}
Um mehr über das Stylen von Bildern zu erfahren, lesen Sie unser Tutorial zu CSS-Bildern .
Um mehr über die CSS-Positionierung zu erfahren, lesen Sie unser CSS-Positionierungs - Tutorial.