“Cómo centrar un elemento de bloque en línea” Código de respuesta

Bloque en línea Centro de alineación

.parent {
  display: flex;
  justify-content: center;
  align-items: center;
}

.child {
  display: inline-block;
}
Selfish Swan

Cómo centrar un elemento de bloque en línea

  display: inline-block;
  position: relative;
  /* Move the element to the right by 50% of the container's width */
  left: 50%; 
  /* Calculates 50% of the element's width, and moves it by that */ 
  /* amount across the X-axis to the left */
  transform: translateX(-50%);
Depressed Dove

Respuestas similares a “Cómo centrar un elemento de bloque en línea”

Preguntas similares a “Cómo centrar un elemento de bloque en línea”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código