Design a Holy Albatross layout using CSS Flexbox with container queries. The component…
- User
Design a Holy Albatross layout using CSS Flexbox with container queries. The component should display as 3 columns if there's room but switch to a single column stack if the container is too narrow, using the flex-basis calculation hack or native @container queries.
- Assistant
Providing Holy Albatross flexbox layout with container queries and fallback
Here's a concise HTML/CSS example combining native container queries for a 3-column flex layout that stacks below a container width threshold, plus a fallback "Holy Albatross" flex-basis calc hack for environments without container query support. Below is a quick example of a “Holy Albatross”‑style 3‑column layout using Flexbox. It falls back to a single column when the parent container is too narrow. The container‑query version is shown first, with a “hack” fallback if container queries aren’t supported.
<div class="albatross"> <div class="card">Card 1</div> <div class="card">Card 2</div> <div class="card">Card 3</div> <div class="card">Card 4</div> <div class="card">Card 5</div> </div>/* Base layout */ .albatross { container-type: inline-size; /* enables @container if supported */ display: flex; flex-wrap: wrap; gap: 1rem; } /* Default: single column */ .card { flex: 1 1 100%; padding: 1rem; background: #eee; border-radius: 6px; } /* Container query: three columns if there’s enough width */ @container (min-width: 48rem) { .card { /* Three columns with a 1rem gap => subtract 2rem total gap */ flex: 1 1 calc((100% - 2rem) / 3); } } /* Fallback for browsers without container queries: “Holy Albatross” flex-basis hack */ @supports not (container-type: inline-size) { .card { /* Set a hinge width (48rem here). Below that, items effectively become 100%; above, they wrap to multiple columns. */ flex: 1 1 calc((48rem - 100%) * 999); } }- By default each
.cardis full width (single column). - Once the container is at least
48remwide, it places three columns. - If container queries aren’t supported, the hack (
calc((48rem - 100%) * 999)) triggers wrapping when the container grows past that hinge value, yielding multiple columns. Adjust the48remto taste.
- By default each
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.