Using Viewport Units for Responsive Layout
📖 Scenario: You are creating a simple webpage layout that adjusts its size based on the browser window size. This helps the page look good on phones, tablets, and desktops without extra work.
🎯 Goal: Build a webpage with a header and a main content area. Use viewport units in CSS so the header height is always 10% of the viewport height and the main content area fills the rest.
📋 What You'll Learn
Create a basic HTML structure with
<header> and <main> elementsUse CSS viewport height units (
vh) to set the header height to 10% of the viewport heightSet the main content area height to fill the remaining 90% of the viewport height
Add background colors to header and main for clear visual distinction
Ensure the layout adjusts automatically when resizing the browser window
💡 Why This Matters
🌍 Real World
Websites need to look good on phones, tablets, and desktops. Using viewport units helps create flexible layouts that adjust automatically to different screen sizes.
💼 Career
Front-end developers use viewport units to build responsive designs that improve user experience across devices.
Progress0 / 4 steps