Guava Avatar

Handy Css pattern

Download

Nothing fancy, just a css helper I keep re-writing.

container-query.css css

Card that grows its type scale with its own container, not the viewport.

.card {
  container-type: inline-size;
  padding: 1rem;
  border-radius: 0.5rem;
  background: var(--surface);
}

.card > h2 {
  font-size: clamp(1rem, 4cqi, 1.75rem);
  margin: 0 0 0.5em;
}

@container (inline-size > 28rem) {
  .card {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.25rem;
  }
}

No tests yet; PRs in the form of forks welcome.

Developer Discussions