Coding task · HTML and CSS course · Module 5: Responsiveness
Mobile First CSS layout
MOBILE-FIRST is the philosophy of 'build from the smallest up' - just like the Egyptians built pyramids from the foundations (base) to the peak! Instead of writing desktop styles and then reducing them for mobile (hard!), we start with mobile (simple) and expand for larger screens (easier). We only use min-width (from this size up), NEVER max-width. Order: base styles (mobile), @media (min-width: 768px) {tablet}, @media (min-width: 1024px) {desktop}. 60% of users are on mobile - that's the foundation!
Task
Create a mobile-first layout for an Egyptian temple. HTML: <div class='temple'><h1>Temple of Ra</h1><p>Description of the temple...</p></div>. CSS - BASE STYLES (mobile, no media query): .temple {width: 100%; padding: 15px; background: #F4E4C1; font-size: 14px;}. Then @media (min-width: 768px) {.temple {width: 80%; margin: 0 auto; padding: 25px; font-size: 16px;}}. Finally @media (min-width: 1024px) {.temple {max-width: 1200px; padding: 40px; font-size: 18px; box-shadow: 0 0 20px rgba(0,0,0,0.2);}}. Watch the progressive enhancement!