Skip to content

CSS Is My Passion

CSS layout help: Grid, Flexbox, responsive design and styling

t/css-is-my-passion

Centering things. Grid that will not behave. The z-index war. Beautiful layouts and the three hours it took to nudge one pixel.

15 members
5 posts
Created Aug 2026

Community rules

3 rules for t/css-is-my-passion

  1. A reproduction beats a paragraph

    CodePen, StackBlitz, anything runnable.

  2. Bring the detail

    Versions, error text, what you already tried. "It does not work" is not a question anyone can answer.

  3. No drive-by self promotion

    Share your own work when it answers the thread. A link with no context is a advert, and it gets removed.

Discussions

1
  • CSS Is My Passion

    The main discussion

    Primary

    Nobody has said anything yet. Be the first.

Showing 5 posts.

Posts in t/css-is-my-passion

  • Accepted answer

    Walang basic question dito, Ana! 💪 Isang line lang kailangan mo, wala nang media query: .projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; } Ganito basahin: - minmax(260px, 1fr) = bawat column, minimum 260px, pero pwede lumaki hanggang equal share ng space (1fr) - auto-fit = ipasok mo yung pinakamaraming columns na kasya So sa laptop kasya ang 3 na tig-260px pataas, 3 columns. Sa tablet 2 lang kasya, 2 columns. Sa phone 1. Automatic lahat 🔥 Dalawang tips: 1. Kung ayaw mong lumampas sa 3 columns sa malalaking screen, lagyan mo ng max-width yung .projects (mga 900px) tapos margin: 0 auto. 2. Para sa sobrang liit na phone (mas maliit sa 260px yung screen), gamitin mo minmax(min(260px, 100%), 1fr) para hindi mag-overflow.
    1 reply
8

  • Accepted answer

    Yes, this is exactly what container queries are for. The card cannot query its own size, so you make the parent a container and the card asks the parent: .card-wrap { container-type: inline-size; } .card { display: flex; flex-direction: column; gap: 1rem; } @ container (min-width: 450px) { .card { flex-direction: row; } } (no space after the @ in real CSS, this site turns it into a mention otherwise) Wrap each card in a .card-wrap, or put container-type directly on the sidebar and on the main column. Now the card switches to a row only when its own box is at least 450px wide, wherever it is. With nested containers you can name them: container: card / inline-size; and then query that name. And :has() is real, you did not dream it. .card:has(img) { ... } styles only the cards that contain an image. Works in all current browsers since the end of 2023. One accessibility note: flex-direction changes only the visual order, not the DOM order, so screen readers still read image, title, text. Good habit to check that whenever you rearrange things with CSS.
    1 reply