@git-ritesh
Posted
I often use display: flex;
, align-items: center;
& justify-content: center;
to center things from both sides i.e. horizontally & vertically.
Though if I have to center a <div>
only on the main axis then I use margin: 0 auto;
to center but it should have a width
for that to be happen as by default any <div>
element is display: block;
and it would take full width
in the parent container.