{
CF
}
Code
Fronts
Back to CSS Grid Layouts
Container-Query Card
Pure CSS
Edit any tab — preview updates live
CSS
HTML
Reset
Copy
.gl-cq { display: grid; grid-template-columns: 1fr 130px; gap: 6px; width: 320px; font-family: system-ui, sans-serif; color: #f0eeff; } .gl-cq-wide, .gl-cq-narrow { container-type: inline-size; } .gl-cq-c { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; background: #18181f; border: 1px solid rgba(124,108,255,0.28); border-radius: 8px; padding: 10px; } .gl-cq-icon { width: 30px; height: 30px; border-radius: 6px; background: linear-gradient(135deg, #7c6cff, #a78bfa); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; flex-shrink: 0; } .gl-cq-c h4 { margin: 0; font-size: 11.5px; color: #fff; } .gl-cq-c p { margin: 0; font-size: 10px; color: #b8b6d4; line-height: 1.4; } @container (min-width: 160px) { .gl-cq-c { flex-direction: row; align-items: center; } }
<div class="gl-cq"> <div class="gl-cq-wide"> <article class="gl-cq-c"> <div class="gl-cq-icon">★</div> <div class="gl-cq-body"> <h4>Wide container</h4> <p>Icon left, text right</p> </div> </article> </div> <div class="gl-cq-narrow"> <article class="gl-cq-c"> <div class="gl-cq-icon">★</div> <div class="gl-cq-body"> <h4>Narrow container</h4> <p>Icon stacks above</p> </div> </article> </div> </div>
Live preview
Ready