Make a flex container

Set display: flex on the parent element. Its direct children become flex items. Use gap for spacing and flex-wrap to let items move onto another line when necessary.

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

Learn more