Parviz Azeroglu• 150
@ParvizAzeroglu
Posted
Generally, I use flex to center items within a container. This means that I write the following code in CSS:
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
However, you can also use margin: auto;
in the body. Such as :
body {
margin: auto;
height: 100vh;
}
But remember that this code is only useful for centering a single item; you can't use it for more than one item.
0