DEV Community

Abraham Alanya
Abraham Alanya

Posted on • Edited on

Centrar con CSS

Usando Display Grid 😎

Forma 1

div {
  display: grid;
  justify-content: center;
  align-items: center;
}
Enter fullscreen mode Exit fullscreen mode

Forma 2

div {
  display: grid;
  place-content: center;
}
Enter fullscreen mode Exit fullscreen mode

Usando display Flex 🥳

div {
  display: flex;
  justify-content: center;
  align-items: center;
}
Enter fullscreen mode Exit fullscreen mode

Usando position absolute 👀

div {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)