I am trying to find a way to add margin-auto to a tailwinds css class, so that I can center an svg image across a container. I can add the attribute in code inspect, but I cannot find the corresponding div tag in my code.
The inspect panel shows the div as tailwinds.css.1, but I don’t have a class with that name. I have tried adding margin-auto to the svg tag itself and all the surrounding div tags, as well as the Logo component in which the svg is defined. None of them work to center the image.
How can I find the name of the div tag from the inspect panel?
<footer className="bg-slate-50">
<Container>
<div className="py-16 display-block mx-auto">
<Logo className="display-block mx-auto" />
3
Answers
In order to inspect the required component you can use the DOM methods. For example if you want to target the
<div className="py-16 display-block mx-auto">
, you can use likeFor centering the Logo, you just to need the
mx-auto
to that component only .I have rewritten your code below.Try to implement this but remember to replace
class
withclassName
.Also you can view the code with more better preview here
Did you tried to change display-block by only block on your logo component ?
display-block doesn’t exist in tailwindcss
mx-auto on the svg should do the trick
https://play.tailwindcss.com/o33Y2yn5KP