How to position text on top of an image using TailwindCSS

https://codepen.io/Ant-Riddle/pen/xxeOJaN I just started using tailwind and I'm reading their docs, got into a bit of a problem trying to use z-index to position text on top of an image
4 Replies
riddle
riddle3mo ago
trying to get something like this
No description
clevermissfox
clevermissfox3mo ago
The easiest way is to use the image as a background image on the container that’s holding the text since it’s a decorative image anyway.
riddle
riddle3mo ago
oh right I was thinking too hard lol it was that simple 😅 but if you had to do it using a image rather than a background image how would you go about it?
clevermissfox
clevermissfox3mo ago
If it had to be an img tag, you could use grid to set the img to grid-column: 1 / -1; grid-row: 1 / -1 and then place the text in the middle columns and rows. Could also use position absolute. Or use a pseudo element for the image.
Want results from more Discord servers?
Add your server
More Posts
React, need to avoid multiple API requests.I have toggle button , on toggle if its on then it opens side drawer, So API requests need to be calHTML question --vscode <header"> added the quote mark, and breaks when removedi have <header"> <main> <section> <header> <article> the first header vs code added the " after theCan I get a confirmation on how browsers handle unsupported CSS syntax?If a browser doesn't support the :has() selector, will it stop interpreting any CSS in that block ofFonts in tailwindcssI was just curious, where does tailwindcss gets its fonts from? I just added this thing inside `exteCSS Custom Property override on a custom element with attribute selectors doesn't work as expectedCan someone here explain to me why the second instance of my `calcite-chip` component isn't styled pWebsite for Discord Botis it good enough? idk did i made it too much for a Discord bot?Force CSS Grid to follow the order of li elements of a ul in the HTML code.I have this code: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meFlexbox, show elipses instead of wrapping when screen shrinks (tsx)Hello, I've been racking my brain figuring out why this code works on codepen but not on my own codeI'm having trouble when deploying on Github PagesPretty ambiguous question but I haven't found a solution yet. I did a quick project with SASS and whWhy does the eyes stand outside of the div and get pushed down?the eyes keep standing outside of the eyes div even though they are in the same class. why is this h