Question about the middle of the elements

css

#1

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


#2

Hi,
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;