I am trying to align a image with some text in the middle of the page. The image gets to the center correctly , but the overlay text is off center. Below is the code. The text should be in the top left of the image.
<div class="w3-content">
<div class="w3-row-padding" style="text-align: center;">
<div class="w3-display-container">
<img src="w3images/house5.jpg" alt="House" style="width:50%;" class="animated fadeInRight slower">
<div class="w3-display-topleft w3-black w3-padding animated fadeInRight slower">Summer House</div>
</div>
</div>
</div>
If you need the text on top of the image, I think you should either use the image as a background image, or use absolute position.
.image-wrap {
position: relative;
margin: 0 auto;
width: 50%;
}
.image-wrap .text {
position: absolute;
top: 0;
}
Did some changes and got this to work.. THanks all
<div class="w3-container animated fadeInRight slower w3-white " style="float: right;">
<div class="w3-display-container" >
<div><img src="w3images/house2.jpg" ></div>
<div class="w3-display-topleft w3-black w3-padding">My Summer House</div>
</div>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.