In this Next.js component, in the highlighted line "mb-3" class of Tailwindcss has no effect in the Y direction but if we use "m-3" it also does not have an effect in the y direction but has an effect on the X direction.
import Image from "next/image";
import Link from "next/link";
const Header = () => {
return (
<div className="bg-blue-200 w-1/5 h-screen fixed px-12 py-9">
<Link href="/" className="mb-3">
<Image
src="/logo.png"
alt="Twizlr"
width={100}
height={0}
priority
className="h-auto"
/>
</Link>
<nav className="flex items-center justify-center h-full bg-yellow-200"></nav>
</div>
);
};
export default Header;
I can’t get it why is this happening?
I don’t know what to do at all.
2
Answers
It worked if I also made the parent div
display: flex
. Thank you!The
<Link>
here would render an<a>
element.<a>
elements are inline elements by default. This means that verticalmargin
does not exhibit any behavior on them. To have the verticalmargin
work, consider overriding their defaultdisplay: inline
value. For example, you could applydisplay: inline-block
as a close equivalent todisplay: inline
.