Flexbox items will not wrap onto the next line on mobile
Hello. I am building a row of product cards with flexbox. On desktop it is fine. On my phone (375px wide) the cards do not go to the next line. They stay in one row and the page scrolls sideways.
Cite
CoursesWeb Forum, "Flexbox items will not wrap onto the next line on mobile", https://coursesweb.net/forum/t/flexbox-items-will-not-wrap-onto-the-next-line-on-mobile/, accessed 2026-11-26..cards { display: flex; gap: 16px; } .card { flex: 0 0 260px; padding: 16px; background: #f4f4f4; }<div class="cards"> <div class="card">One</div> <div class="card">Two</div> <div class="card">Three</div> </div>I expected the third card to go below the others. In DevTools the .cards box is 375px wide, but each card is 260px, so they go outside of it. I tried width: 100% on .card, but then my desktop layout is broken. What am I missing? Thank you.
Write something first.
Give people something to work with: at least 30 words on what happened and what you tried.
That is too long. Keep it under 6,000 characters.
Write the question as the title, 15 to 140 characters, no links.
Pick a category.
Add a name (2 to 40 characters, no links).
That email address does not look right.
That was quick. Read the thread, then try again.
The form expired. Reload the page and post again.
Something went wrong with the form. Reload and try again.
Please complete the check and post again.
Limit reached for now. Try again later.
This thread is closed to new replies.
This thread no longer accepts replies.
Something went wrong with the form. Reload and try again.
Post a reply or question first (name and email), then this browser can vote, edit and accept answers.
You cannot vote on your own post.
Only the author (within 30 days) or the forum team can do that.
That email already has an account. Use your sign-in link instead.
New accounts are paused for the moment. Try again later.
That was already posted.