I have the following HTML element, which appears as shown.
<div className="flex col-span-2 row-span-2 h-screen border-blue-500 border-4 justify-center items-center">
<div className='flex bg-blue-300 h-full w-full justify-center items-center '>
<div className='text-4xl'>some text</div>
</div>
</div>
I would like to have a margin between the blue background and the border like this:
,
where the margin is the same size (say, 16px) all the way around. How can I achieve this by modifying the above code?
I know I can use h-[90%] w-[90%]
to get a similar effect, however I want the margin size to be constant instead of depending on the height and the width. I have tried to use the tailwind margin properties, but I cannot figure it out.
Thanks for the help.
2
Answers
To achieve a constant margin between the blue background and the border in your HTML code, you can modify the existing classes and add an additional wrapper <div element..
Here’s an updated version of your code:
Hope I could help,
Regards,
Jonasz
Adding padding to the inside div should do the trick:
p-4 will add 16px of padding on each side.