MÓDULO_TEÓRICO
Media Queries and Mobile-First Strategy

Seamless Adaptation Across All Screens
Today, over 60% of all web traffic originates from mobile devices. Designing for a massive desktop monitor first and then trying to "force-shrink" it for mobile almost always generates messy, bug-prone CSS.
The Mobile-First Strategy dictates designing the clean, lightweight mobile version first (base styles), and then using @media (min-width: ...) queries to expand layouts as the screen widens.
1. Industry Standard Breakpoints
- Mobile: Base default styles (no media query required).
- Tablet / Medium Screens:
@media (min-width: 768px) - Desktop / Laptops:
@media (min-width: 1024px) - Large / UltraWide Displays:
@media (min-width: 1440px)
2. Transforming Nexus Dashboard to Mobile-First
css/* ======================================= 1. BASE STYLES: MOBILE (Default) ======================================= */ .dashboard-layout { display: flex; flex-direction: column; /* Single column stack on mobile */ } .sidebar { display: none; /* Hide or collapse sidebar into drawer */ } .metrics-grid { display: grid; grid-template-columns: 1fr; /* 1 card per row */ gap: 16px; } .data-table-wrapper { overflow-x: auto; /* Horizontal scroll prevent table clipping */ } /* ======================================= 2. TABLET (min-width: 768px) ======================================= */ @media (min-width: 768px) { .metrics-grid { grid-template-columns: repeat(2, 1fr); /* 2 cards per row */ } } /* ======================================= 3. DESKTOP (min-width: 1024px) ======================================= */ @media (min-width: 1024px) { .dashboard-layout { display: grid; grid-template-columns: 260px 1fr; grid-template-rows: 70px 1fr; grid-template-areas: "sidebar header" "sidebar content"; } .sidebar { display: block; grid-area: sidebar; } .metrics-grid { grid-template-columns: repeat(3, 1fr); /* 3 cards per row */ } }
3. Golden Rule: Prevent Accidental Horizontal Scroll
If your web page scrolls sideways on mobile, check for elements with width: 100vw or hardcoded pixel widths wider than 320px. Always rely on max-width: 100%.
