Question about the middle of the elements

My English is not good. Please help me with programming problems…

Hi, I want to know what is the difference between the three elements? I mean to middle the elements.

margin: auto;

display: inline-block;

display: flex;

thank you

I’m going to assume you meant “how to center” elements with the properties you listed.

To center a block level element with margin: auto; it needs a width or min/max width.

To center an element that is display:inline-block; you would set text-align:center; on the parent.

To center an element with display:flex; you would use justify-content: center;


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.