Lecture
Notes
A Hands-On Guide to Responsive Web Design
Learn the basics by seeing and interacting with the code.
What is Responsive Web Design?
Responsive Web Design (RWD) is an approach that makes web pages render well on a variety of devices and window or screen sizes. Content, design, and performance are necessary across all devices to ensure usability and satisfaction.
The core principles of RWD are:
- The Viewport Meta Tag: This tag tells the browser how to control the page’s dimensions and scaling. Without it, your responsive code may not work correctly on mobile devices.
- Fluid Grids: Using relative units like percentages (%) or flexbox/grid instead of fixed units like pixels (px) for column widths.
- Flexible Images: Using rules to ensure images scale down to fit within their containing element, rather than overflowing.
- Media Queries: The magic of RWD. This allows you to apply different CSS rules based on the device’s characteristics, most commonly its width.
Example 1: A Basic Two-Column Layout
This is the most fundamental concept. A non-responsive layout with fixed widths will break on small screens, forcing users to scroll horizontally. A responsive layout will adapt, often by stacking the columns vertically.
Live Demo
Click and drag the bottom-right corner of the box below to see the difference in behavior.