I've been playing around with this issue for a while. Stack Overflow suggested this link to take a look and see if that solve my question but it is not quite the case here, because the is no image related and there is no relative and absolute position involve which I think is key in this approach.
I want to set up an overflow-y
when some text exceeds the height of an image in the background. So far I got two approaches:
- One where I can center the text but it cuts off when overflow is called.
- Another one where I cannot center the text (it stays up) but overflow is working fine.
The following block do not center vertically the text:
<div class="w-full text-md border border-red-600">
<div class="relative">
<img class="w-full h-96" src="https://i.imgur.com/hAodNjT.jpg" />
<div class="flex justify-between items-center absolute h-full top-0 w-full sm:w-1/2" style="background-color: rgba(255, 255, 255, 0.7)">
<div class="overflow-auto h-full">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
</div>
</div>
</div>
The following block cut off the text from the top:
<div class="w-full text-md border border-red-600">
<div class="relative">
<img class="w-full h-96" src="https://i.imgur.com/hAodNjT.jpg" />
<div class="flex justify-between items-center absolute h-full overflow-auto top-0 w-full sm:w-1/2" style="background-color: rgba(255, 255, 255, 0.7)">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
</div>
</div>
Any feedback is welcome.