RWD
Responsive Web Design
Created by Saurav Kumar
"with great website comes greater responsivity"
Content
- Overview
- Concept
- Ingredients
- Resources
Web Developers - Medium
- Dimension is required
- Establish a boundary
Browser - our canvas
- Imperfections
- Wide range of devices
Failed attempts to cater to all devices
- Quarantined URL
- Separate mobile sites
Ethan Marcotte
- Architecture
- Artists experiment with surfaces that react with voice
- Smartglass - It responds to presence of occupants in a meeting room by
Ethan Marcotte advocates we shift our design thinking to appropriate constraints associated with coding for an array of devices: using fluid grids, flexible images, and media queries, he shows us how to embrace the “ebb and flow of things” with responsive web design.
Prerequisites
HTML
CSS
Passion
Principles - What is RWD?
An approach to web design aimed at crafting web applications to provide an optimal viewing and interaction experience—easy reading and navigation with a minimum of resizing, panning, and scrolling—across a wide range of devices
- Flexible grid based layout - allows layout to reflow to the screensize of any device
- Flexible content - allows content such as images, videos, text to reflow with the layout
- CSS3 Media Queries - allows to control each variation of the layout so that content is displayed optimally in all devices
Terms - RWD confused with
-
Progressive Enhancement It is the principle if starting with rock-solid foundation and then adding enhancements if you know user-agents can handle the improved experience.
-
Adaptive Web Design It is just another term for progressive enhancement, it takes into account varying levels of markup, css, js and assitive tech. support. It focuses on broader approach than RWD.
-
Mobile First It is all about designing the entire experience for small screen devices, prioritizing the functionalities based on constraints of smaller screen. Because, it's always much harder to design for smaller screen after wider screen.
three shades
Ingredients
What makes up a responsive web design?
Flexible Grid
Flexible Content
Media Queries
Grid - Components
Row
.row{ clear: both; overflow: hidden }
Columns
.col{ overflow: hidden; margin-bottom: 1em }
Column range classes
.m-2col { width: 100% }.m-1col { width: 46% }
Inline images
Can be reduced and increased in size but not beyond its maximum size
img{ max-width: 100%; vertical-align: middle; border: 0 }
Background images
Property - background-size: contain - the contain value will scale the image (while maintaining the aspect ratio) so that the entire image can fit inside the background area
div{ background-size: contain }
cover - the cover value will scale the image (while keeping the aspect ratio) to the smallest size that will completely cover the background area
div{ background-size: cover }
How can we create responsive background images?
Methods for responsive background images
Fixed-height method
This method sets a height on the container, and lets the background image "crop" as the layout is reduced in width
.responsive-img { width: 100%; height: 300px; background-image: url(bkg_img.jpg); background-size: cover; background-position: center }
Scaled-height method
It uses percentage value for height, and the height is a ratio of the with. This ensures that the aspect ratio remains correct, no matter how wide or narrow the container becomes
.responsive-img { width: 100%; padding-bottom: 50%; background-image: url(bkg_img.jpg); background-size: cover; background-position: center }
How did we get this 50% for padding-bottom?
Calculate the ratio between height and width or the image and convert this into a percentage. E.g. 300px/600px = 0.5; 0.5*100 = 50%
Responsive video
3 steps method
- Wrap the video inside a parent container
- Style the video container so that it has the correct aspect ratio
- Make the video stretch to fit the dimensions of the box
Media Queries
A module from the CSS3 specification
Breakpoints
Points where RWD layout adapts or changes based on specific media queries
How can one determine the breakpoints?
Caution
<!-- css3-mediaqueries.js for IE less than 9 -->
<!-- [if lt IE 9]>
<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->
RWD
Responsive Web Design
Created by Saurav Kumar
"with great website comes greater responsivity"