CSS
centering-a-div
You will learn to center an item in 4 different ways.
.container { display: flex; justify-content: center; align-items: center; }
.container { display: grid; justify-content: center; align-items: center; }
.container { display: grid; place-items: center; }
div { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
div { width: 1500px; margin: auto; }
When using Position or Margin for centering, we need to target the element not it's parent element.