Catalog / Responsive Web Design Cheatsheet
Responsive Web Design Cheatsheet
A quick reference guide to building responsive websites, covering viewport settings, media queries, flexible layouts, and responsive images.
Viewport & Basic Setup
Setting the Viewport
The viewport meta tag controls how a webpage scales on different devices. It’s essential for responsive design.
|
Example of disabling zooming:
|
Basic HTML Structure
A basic HTML5 structure to start with:
|
Media Queries
Media Query Syntax
Media queries allow you to apply different styles based on the characteristics of the device, such as screen size, orientation, and resolution.
|
Common Media Features:
|
Common Breakpoints
Common breakpoints are screen sizes at which your layout changes to adapt to different devices. These are just suggestions; choose breakpoints that work best for your content.
|
Example Media Queries
|
Flexible Layouts
CSS Flexible Box Layout (Flexbox)
Flexbox is a powerful layout module that makes it easier to design flexible and responsive layouts.
|
Example:
|
CSS Grid Layout
CSS Grid Layout is a two-dimensional layout system that allows you to create complex layouts with rows and columns.
|
Example:
|
Relative Units
Using relative units like percentages (
|
Responsive Images
The `srcset` Attribute
The
|
The `<picture>` Element
The
|
CSS `object-fit` Property
The
|