I am trying to get three images in a line within a div
without spaces and have text display over each of the images that will click through to a different page. I understand the solution to this probably lies in the position of both elements but I cannot seem to get the text to stay over the correct image. If someone could help me with this that would be great?
Below is the HTML.
<div class="services">
<div id="text-overlay">
<img src="Untitled-5.jpg">
<p>Landscaping</p>
</div>
<div id="text-overlay">
<img src="Untitled-6.jpg">
</div>
<div id="text-overlay">
<img src="Untitled-7.jpg">
</div>
</div>
And the CSS:
#text-overlay {
position: relative;
}
img {
display: block;
width: 33.3333333333%;
float: left;
height: 250px;
}
#text-overlay p {
position: absolute;
top: 1%;
left: 1%;
background-color: firebrick;
color: white;
padding: 1%;
}
Any help would be appreciated. Is this the best way to do it or are there better alternatives?