Horizontal-vertical centering of content in DIV

If the horizontal centering of a box (DIV) can be done relatively easily with the “margin: 0 auto;” property, vertically it is a little more delicate, but not overly difficult. We will display one of the multiple methods.

.div_centr_ext can have width:max-content; if contextual adjustment is desired; however, a min-width property could also be inserted.

If we are only interested in vertically centered alignment, we can consider, at .div_centr_int, instead of:

to use:

Author: Ovidiu.S

I am quite passionate about this professional area as if I know something - no matter how little - I want to share it with others.

Leave a Reply