顯示具有 margin 標籤的文章。 顯示所有文章
顯示具有 margin 標籤的文章。 顯示所有文章

2020年4月24日 星期五

[CSS] Meaning of margin:auto

Background
Sometimes we need to fulfill situation which we want to line up several components in a row and the last component leans on the right most of the div

Solutions
This comes to marginLeft/Right: auto, when we try to mark the container component with margin-left: auto, the container takes all the spaces available to the left hence position the switch button at the right most of the container.
That explains why when we left / right margin the DIV, we can center it at the center.

References