When working with absolute positioned elements, it's important to consider their positioning in relation to the nearest relative element. To keep absolute position boundaries contained within a specific area, you can set the parent element's position to relative.
.thumbnail a {
position: relative;
display: block;
}
In this scenario, applying the above code would be beneficial as the .text-content
element is positioned within the a
tag.
.thumbnail a {
position: relative;
display: block;
}
span.text-content {
position: absolute;
top: 10px;
left: 15px;
color: #fff;
font-size: 24px;
}
<div class="thumbnail">
<a href="">
<img src="http://placehold.it/580x278/333333/" alt="" />
<span class="text-content"><span>Shop Buckets</span></span>
</a>
</div>
<div class="thumbnail">
<a href="">
<img src="http://placehold.it/580x278/333333/" alt="" />
<span class="text-content"><span>Shop Bags</span></span>
</a>
</div>