Cursor mobile

CSS Grid Layout Breaking on Small Screens in Cursor App

Your Cursor-generated CSS Grid layout looks great on desktop but completely breaks on mobile screens. Grid items overflow horizontally, content gets cut off, columns become impossibly narrow, or the layout collapses into an unreadable single column with wrong proportions.

CSS Grid is powerful but requires careful handling of responsive behavior. Cursor often generates grid layouts optimized for the desktop view you described in your prompt, using fixed column counts or pixel-based track sizes that don't adapt to smaller viewports. The grid might use grid-template-columns: repeat(4, 1fr) which creates four equal columns even on a 320px screen.

The issue manifests as horizontal scrolling, overlapping text, images squeezed to unusable sizes, or grid items that stack but retain incorrect heights and spacing from the desktop layout.

Error Messages You Might See

Horizontal scroll on mobile Grid items overflowing container Content cut off on small screens Layout shift when rotating device
Horizontal scroll on mobileGrid items overflowing containerContent cut off on small screensLayout shift when rotating device

Common Causes

  • Fixed column count without responsive breakpoints — Using repeat(4, 1fr) or repeat(3, 250px) which forces the same number of columns on all screen sizes
  • No minmax() usage — Grid tracks use fixed sizes instead of minmax(min, max) which would allow them to shrink and grow
  • Grid gap too large for mobile — A gap of 32px or 48px that's fine on desktop eats into content space on a 375px screen
  • Fixed pixel widths on grid items — Grid children have hardcoded width values that exceed the grid track size on small screens
  • Auto-fill vs auto-fit confusion — Cursor used auto-fill when auto-fit was needed, or vice versa, causing empty tracks or content not stretching
  • Missing overflow handling on grid items — Text or images inside grid items overflow their boundaries without wrapping or scaling

How to Fix It

  1. Use auto-fit with minmax() — Replace fixed column counts with grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) which automatically adjusts column count based on available space
  2. Add responsive grid breakpoints — Use media queries to change the grid: 1 column on mobile (<768px), 2 on tablet, 3-4 on desktop
  3. Scale gap with viewport — Use gap: clamp(1rem, 2vw, 2rem) or responsive gap values in media queries so spacing adapts to screen size
  4. Set max-width: 100% on grid children — Prevent images, tables, and other content from overflowing grid cells with max-width: 100%; overflow: hidden;
  5. Test at key breakpoints — Check your grid at 320px (iPhone SE), 375px (iPhone), 768px (tablet), and 1024px+ (desktop) in DevTools
  6. Consider Flexbox for simple layouts — If your layout is a single row that wraps, display: flex; flex-wrap: wrap; may be simpler and more robust than Grid

Real developers can help you.

Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture zipking zipking I am a technologist and product builder dedicated to creating high-impact solutions at the intersection of AI and specialized markets. Currently, I am focused on PropScan (EstateGuard), an AI-driven SaaS platform tailored for the Japanese real estate industry, and exploring the potential of Archify. As an INFJ-T, I approach development with a "systems-thinking" mindset—balancing technical precision with a deep understanding of user needs. I particularly enjoy the challenge of architecting Vertical AI SaaS and optimizing Small Language Models (SLMs) to solve specific, real-world business problems. Whether I'm in a CTO-level leadership role or hands-on with the code, I thrive on building tools that turn complex data into actionable value. Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. Matthew Jordan Matthew Jordan I've been working at a large software company named Kainos for 2 years, and mainly specialise in Platform Engineering. I regularly enjoy working on software products outside of work, and I'm a huge fan of game development using Unity. I personally enjoy Python & C# in my spare time, but I also specialise in multiple different platform-related technologies from my day job. rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems Nam Tran Nam Tran 10 years as fullstack developer Matthew Butler Matthew Butler Systems Development Engineer @ Amazon Web Services Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. PawelPloszaj PawelPloszaj I'm fronted developer with 10+ years of experience with big projects. I have small backend background too

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

What is the difference between auto-fill and auto-fit?

auto-fill creates as many tracks as will fit, even if they're empty. auto-fit collapses empty tracks so remaining items stretch to fill the row. For most responsive layouts, auto-fit is what you want because it ensures items fill the available width.

Should I use CSS Grid or Flexbox for responsive layouts?

Use Grid for two-dimensional layouts (rows AND columns) like card grids, dashboards, and page layouts. Use Flexbox for one-dimensional layouts (a single row or column) like navigation bars, button groups, or card content. Many responsive designs use both together.

Related Cursor Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help