How to make text visible over svg image in tailwind css?

by herminia_bruen , in category: HTML & CSS , 4 months ago

How to make text visible over svg image in tailwind css?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by scotty_walker , 4 months ago

@herminia_bruen 

To make text visible over an SVG image in Tailwind CSS, you can use the z-index property to layer the text on top of the SVG image. Here is an example of how you can achieve this:

1
2
3
4
<div class="relative">
    <img src="image.svg" class="w-full h-full" alt="SVG Image">
    <p class="absolute top-0 left-0 z-10 text-white bg-black p-2">Text here</p>
</div>


In this example, the relative class on the parent div creates a positioning context for the absolute positioned text element. The z-10 class sets the z-index of the text element to be higher than the SVG image, allowing it to appear on top. You can adjust the positioning and styling of the text element by using Tailwind CSS utility classes.