SlideShare a Scribd company logo
RESPONSIVE WEB
DESIGN
Created by Vladimir Zhydal
WHAT?
Responsive Web Design (RWD) is an approach to web
design aimed at crafting sites to provide an optimal viewing
experience across a wide range of devices.
ONE SITE FOR EVERY SCREEN
WHY?
Day by day, the number of devices,
platforms, and browsers that need to work
with your site grows. Responsive web
design represents a fundamental shift in
how we’ll build websites for the decade to
come.
Jeffrey Veen
WEB STATISTICS
HISTORY
2004
A site layout example that adapts to browser viewport
width was first demonstrated by Cameron Adams.
2009
CSS3 media queries were almost ready for prime time.
2010
Ethan Marcotte coined the term responsive web design.
2012
Responsive design was listed as #2 in Top Web Design
Trends.
HOW CAN WE DO RESPONSIVE?
viewport
media queries
flexible images and media
adaptive images
grids
flexbox
responsive tables
VIEWPORT
VIEWPORT BASICS
DEVICE PIXELS AND CSS PIXELS
Device pixels give the formal resolution of whichever
device you’re working on.
At zoom level 100% one CSS pixel is exactly equal to one
device pixel.
Zooming to 200% makes one CSS pixel grow to four times
the size of one device pixels.
VIEWPORT BASICS
THE DESKTOP VIEWPORT
The function of the viewport is to constrain the <html>
element, which is the uppermost containing block of your
site.
The <html> element takes 100% of the width of that
viewport.
The viewport has the width and height of the browser
window — on desktop.
VIEWPORT BASICS
THE MOBILE VIEWPORTS
The visual viewport is the part of the
page that’s currently shown on-
screen.
The CSS layout, especially percentual
widths, are calculated relative to the
layout viewport.
VIEWPORT META TAG
A meta viewport tag gives instructions on how to control the
page's dimensions and scaling.
VIEWPORT META TAG HISTORY
It was first implemented by Apple for the Safari/iPhone
browser, but has since been implemented for most of
mobile browsers.
VIEWPORT META TAG SYNTAX
<meta name="viewport" content="width=device­width, initial­scale=1">
VIEWPORT META TAG BASICS
default width=device-width
VIEWPORT META TAG PROPERTIES
Property Description
width Width of the viewport in pixels (or device-width). If width isn’t
set, it defaults to a desktop size (980px on mobile Safari).
height Height of the viewport in pixels (or device-height). Generally
you don’t need to worry about setting this property.
initial-
scale
(0 to 10.0) Multiplier that sets the scale of the page after its
initial display. Safe bet: if you need to set it, set it to 1.0.
Larger values = zoomed in, smaller values = zoomed out
VIEWPORT META TAG PROPERTIES
Property Description
minimum-
scale
(0 to 10.0) The minimum multiplier the user can “zoom out”
to. Defaults to 0.25 on mobile Safari.
maximum-
scale
(0 to 10.0) The minimum multiplier the user can “zoom in”
to. Defaults to 1.6 on mobile Safari.
user-
scalable
(yes/no) Whether to allow a user from scaling in/out
(zooming in/out). Default to “yes” on mobile Safari.
CSS @VIEWPORT
The @viewport rule consists of the @-keyword followed by a
block of property declarations describing the viewport.
@viewport {
    width: 980px;
    min­zoom: 0.25;
    max­zoom: 5;
}
CSS @VIEWPORT PROPERTIES
Property Description
width Sets both max and min-width. It's a shorthand descriptor.
auto | device-width | length | percentage
max-width auto | device-width | length | percentage
min-width auto | device-width | length | percentage
orientation Lock orientation or leave to auto.
auto; // auto | portrait | landscape
CSS @VIEWPORT PROPERTIES
Property Description
zoom 'zoom' equates to 'initial-scale' in meta tag.
auto | number | percentage
max-zoom Largest allowed zoom factor.
min-zoom Smallest allowed zoom factor.
user-zoom Equates to 'user-scalable' in meta tag.
fixed | zoom
SUMMARY
Use a meta viewport tag to control the width and scaling
of the browsers viewport.
Include width=device-width to match the screen's width
in device independent pixels.
Include initial-scale=1 to establish a 1:1 relationship
between CSS pixels and device independent pixels.
Ensure your page is accessible by not disabling user
scaling.
MEDIA QUERIES
MEDIA QUERIES
Media queries let the presentation of content be tailored to
a specific range of output devices without having to change
the content itself.
SYNTAX
A media query consists of a media type and zero or
more expressions that check for the conditions of
particular media features
<link rel="stylesheet" media="screen and (color)" href="ex.css">
@import url("ex.css") screen;
@media (min­width:500px) { … }
LOGICAL OPERATORS
and
or
not
only
@media (min­width:500px) and (orientation:landscape){ … }
@media (min­width:500px), (max­height:500px){ … }
@media not screen and (color){ … }
@media only screen and (color){ … }
MEDIA TYPES
Type Description
all Suitable for all devices.
braille Intended for braille tactile feedback devices.
embossed Intended for paged braille printers.
handheld Intended for handheld devices (typically small screen,
limited bandwidth).
print Intended for paged material and for documents viewed on
screen in print preview mode.
MEDIA TYPES
Type Description
projection Intended for projected presentations, for example
projectors.
screen Intended primarily for color computer screens.
speech Intended for speech synthesizers.
tty Intended for media using a fixed-pitch character grid (such
as teletypes, terminals, or portable devices with limited
display capabilities). 
tv Intended for television-type devices (low resolution, color,
limited-scrollability screens, sound available).
MEDIA FEATURES
Property Description
aspect-
ratio
is defined as the ratio of the value of the ‘width’ media
feature to the value of the ‘height’ media feature.
color describes the number of bits per color component of the
output device.
color-
index
describes the number of entries in the color lookup table of
the output device.
device-
aspect-
ratio
is defined as the ratio of the value of the ‘device-width’ media
feature to the value of the ‘device-height’ media feature.
MEDIA FEATURES
Property Description
device-
height
describes the height of the rendering surface of the output
device.
device-
width
describes the width of the rendering surface of the output
device.
grid is used to query whether the output device is grid or
bitmap.
height describes the height of the targeted display area of the
output device.
MEDIA FEATURES
Property Description
monochrome describes the number of bits per pixel in a monochrome
frame buffer.
orientation is ‘portrait’ when the value of the ‘height’ media feature
is greater than or equal to the value of the ‘width’ media
feature.
resolution describes the resolution of the output device, i.e. the
density of the pixels.
scan describes the scanning process of "tv" output devices.
width describes the width of the targeted display area of the
output device.
JS API
var widthQuery = window.matchMedia("(min­width: 600px)");
if (widthQuery.matches) {
    /* the viewport is at least 600 pixels wide */
} else {
    /* the viewport is less than 600 pixels wide */
}
JS API: MEDIAQUERYLIST
matches
Boolean whether the query matched or not.
media
Serialized media query list.
addListener
Adding event listener to a media query. Listener is
invoked when the media query's evaluated result
changes.
removeListener
Removing event listener from a media query.
SUMMARY
Media queries can be used to apply styles based on device
characteristics.
Use min-width over min-device-width to ensure the
broadest experience.
FLEXIBLE IMAGES AND
MEDIA
FLEXIBLE IMAGES
img {
    max­width: 100%;
}
FLEXIBLE VIDEO
video {
    max­width: 100%;
}
FLEXIBLE AUDIO
audio {
    width: 100%;
}
FLEXIBLE SVG
Modern browsers make svg flexible from the box. For old
browsers a padding 'workaround' can be used.
.svg­container {
  display: inline­block;
  position: relative;
  width: 100%;
  padding­bottom: 100%;
  vertical­align: middle;
  overflow: hidden;
}
.svg­content {
  display: inline­block;
  position: absolute;
  top: 0;
  left: 0;
}
FLEXIBLE CANVAS
If you resize the canvas, the drawn content is always erased.
You can either redraw the content after resizing.
var previousWidth = window.innerWidth;
var resizeCanvas = function(context){
  canvas.width = window.innerWidth;
  canvas.height = window.innerHeight;
  scale = window.innerWidth/previousWidth;
  context.scale(scale, scale);
  drawRectangle(context);
};
window.addEventListener('resize',
    resizeCanvas.bind(null, context),
    false);
ADAPTIVE IMAGES
SRCSET
A list of one or more strings separated by commas
indicating a set of possible image sources for the user
agent to use.
Getting images to scale efficiently across varying viewport
widths and screen resolutions.
SRCSET
WIDTH DESCRIPTOR PIXEL DENSITY DESCRIPTOR
<img
srcset="
    imgs/large.jpg 1920w,
    imgs/medium.jpg 960w,
    imgs/small.jpg 480w"
src="imgs/medium.jpg"
alt="Details."/>
<img
srcset="
    imgs/large.jpg 1x,
    imgs/medium.jpg 2x,
    imgs/small.jpg 3x"
src="imgs/medium.jpg"
alt="Details."/>
SIZES
A list of one or more strings separated by commas
indicating a set of source sizes.
Source size values specify the intended display size of the
image.
SIZES
<img
srcset="
    imgs/large.jpg 1920w,
    imgs/medium.jpg 960w,
    imgs/small.jpg 480w"
sizes="(min­width: 33em) 33em, 100vw"
src="imgs/medium.jpg"
alt="Details."/>
That says: is the viewport wider than 33em? This image will
be 33em wide. Otherwise, it’ll be 100vw.
PICTURE AND ART DIRECTION
srcset if you’re lazy, picture if you’re crazy.
Mat Marquis
ART DIRECTION
Tailoring image content to fit specific environments.
Sometimes this means cropping an image.
Other times, it can mean a different image altogether
that may have different proportions or may be changed
in other ways to communicate more effectively in a
layout.
PICTURE
<picture>
    <source media="(orientation: landscape)" srcset="landscape.jpg" />
    <img src="portrait.jpg" alt="A rad wolf." />
</picture>
PICTURE
<picture>
    <!­­ 16:9 crop ­­>
    <source
            media="(min­width: 36em)"
            srcset="imgs/large.jpg  1920w,
                    imgs/medium.jpg  960w,
                    imgs/small.jpg   480w" />
    <!­­ square crop ­­>
    <source
            srcset="imgs/large­square.jpg  822w,
                    imgs/medium­square.jpg 640w,
                    imgs/small­square.jpg  320w" />
    <img
            src="imgs/medium.jpg"
            alt="Details." />
</picture>
SOURCE TYPE
<picture>
    <source type="image/svg+xml" srcset="logo.svg" />
    <source type="image/webp" srcset="logo.webp" />
    <img src="logo.png" alt="RadWolf, Inc." />
</picture>
If the browser supports a source’s type, it will send that
source’s srcset to the img.
GRIDS
GRIDS LIBRARIES
Skeleton
Neat
Simple Grid
csswizardry-grids
Profound Grid
Griddle
Extra Strength Responsive Grids
Proportional Grids
Dead Simple Grid
Responsive Grid System
...
Most of CSS frameworks contain their own grid systems
GRIDS LIBRARIES BASICS
GRIDS LIBRARIES BASICS
.grid {
    margin­right: ­30px;
}
.grid:after {
    display: table;
    clear: both;
    content: '';
}
[class^='grid­col­'] {
    float: left;
    box­sizing: border­box;
    min­height: 1px;
    padding­right: 30px;
}
.grid­col­1­1 {
    width: 100%;
}
.grid­col­2­3, .grid­col­8­12 {
    width: 66.66%;
}
.grid­col­1­2, .grid­col­6­12 {
    width: 50%;
}
.grid­col­1­3, .grid­col­4­12 {
    width: 33.33%;
}
.grid­col­1­4, .grid­col­3­12 {
    width: 25%;
}
RESPONSIVE GRIDS
Extra small
devices
Phones (<768px)
Small
devices
Tablets (≥768px)
Medium
devices
Desktops (≥992px)
Large
devices
Desktops (≥1200px)
Grid
behavior
Horizontal at
all times
Collapsed to start, horizontal above
breakpoints
Container
width
None (auto) 750px 970px 1170px
Class
prefix
.col‐xs‐ .col‐sm‐ .col‐md‐ .col‐lg‐
FLEXBOX
FLEXBOX TERMINOLOGY
FLEXBOX BASICS
Flex container
Flex items
FLEXBOX BASICS
FLEX CONTAINER
display
defines a flex container.
flex-direction
establishes the main-axis.
flex-wrap
allows the items to wrap.
flex-flow
is a shorthand flex-direction and flex-wrap properties.
FLEXBOX BASICS
FLEX CONTAINER
justify-content
defines the alignment along the main axis.
align-items
defines the default behaviour for how flex items are laid
out along the cross axis on the current line.
align-content
aligns a flex container's lines within when there is extra
space in the cross-axis.
FLEXBOX BASICS
FLEX ITEMS
order
controls the order in which flex items appear in the flex
container.
flex-grow
defines the ability for a flex item to grow if necessary.
flex-shrink
defines the ability for a flex item to shrink if necessary.
FLEXBOX BASICS
FLEX ITEMS
flex-basis
defines the default size of an element before the
remaining space is distributed.
flex
is the shorthand for flex-grow, flex-shrink and flex-basis
combined.
align-self
allows the default alignment to be overridden for
individual flex items.
RESPONSIVE TABLES
SCALE
DESKTOP MOBILE
SCROLL TO THE RIGHT
DESKTOP MOBILE
CONTENT: ATTR(DATA-CONTENT)
DESKTOP MOBILE
ADVICES
USE RELATIVE UNITS
A key concept behind responsive design is fluidity and
proportionality as opposed to fixed width layouts.
DON’T USE RELATIVE UNITS
Don’t use relative units everywhere. Ask yourself a question:
Is this property depending on the viewport
width?
CHOOSE CORRECT BREAKPOINTS
Defining breakpoints based on specific devices, products,
brand names, or operating systems that are in use today
can result in a maintenance nightmare. 
The content itself should determine how the layout
adjusts to its container.
‘MOBILE’ FIRST
Use the simplest layout as a start point.
Forces You to Focus on Core Content and Functionality.
In most cases this approach will get less css styles
overrides.
DON’T USE MIN-DEVICE-WIDTH
creating queries based on *-device-width; is strongly
discouraged.
DON’T USE ABSOLUTE VALUES FOR
DEFINING VIEWPORT
USE CSS PREPROCESSORS
Use CSS preprocessors to define bundles
@phone = ~’320px’
PREVIEWING &
TESTING
EXTERNAL RESOURCES
Responsinator.com
displays as numerous devices
iOS Simulator
if you have a Mac. (After launching Xcode, go into
the Xcode menu and chooseOpen Developer Tool > iOS
Simulator)
Browserstack
for cross browser and device testing.
BROWSER DEVTOOLS
Chrome
DevTools Device Mode
Firefox
Responsive Design View
TEST ON REAL DEVICES
Nothing beats holding a device and touching a site.
How far do you need to reach to tap something?
How well does the device respond?
RESOURCES
https://developer.mozilla.org/en-
US/docs/Web_Development/Mobile/Responsive_design
http://alistapart.com/article/responsive-images-in-practice
https://html.spec.whatwg.org/multipage/embedded-
content.html#attr-picture-source-media
http://www.quirksmode.org/mobile/viewports.html
https://developers.google.com/web/fundamentals/layouts/in
hl=en
https://developer.mozilla.org/en-
US/docs/Mozilla/Mobile/Viewport_meta_tag
https://css-tricks.com/snippets/css/a-guide-to-flexbox

More Related Content

PPTX
CSS3 Media Queries And Creating Adaptive Layouts
PDF
CSS3, Media Queries, and Responsive Design
PPTX
Bootstrap 5 ppt
PDF
Bootstrap 5 basic
PPTX
Bootstrap PPT Part - 2
PPTX
Html5 and-css3-overview
PPTX
Bootstrap grids
PPTX
Bootstrap PPT by Mukesh
CSS3 Media Queries And Creating Adaptive Layouts
CSS3, Media Queries, and Responsive Design
Bootstrap 5 ppt
Bootstrap 5 basic
Bootstrap PPT Part - 2
Html5 and-css3-overview
Bootstrap grids
Bootstrap PPT by Mukesh

What's hot (20)

PPTX
Java script
PDF
CSS3 Media Queries
PPT
Introduction to BOOTSTRAP
PPTX
Bootstrap
PPT
Introduction to CSS
PPTX
Presentation of bootstrap
PDF
CSS Day: CSS Grid Layout
ODP
CSS Basics
PDF
Basics of JavaScript
PPTX
Beginners css tutorial for web designers
PPTX
Page layout with css
PDF
Responsive web design
PDF
Responsive Design Presentation
PPTX
Front end web development
PDF
Flutter state management from zero to hero
PDF
Bootstrap
PPTX
Responsive web designing ppt(1)
Java script
CSS3 Media Queries
Introduction to BOOTSTRAP
Bootstrap
Introduction to CSS
Presentation of bootstrap
CSS Day: CSS Grid Layout
CSS Basics
Basics of JavaScript
Beginners css tutorial for web designers
Page layout with css
Responsive web design
Responsive Design Presentation
Front end web development
Flutter state management from zero to hero
Bootstrap
Responsive web designing ppt(1)
Ad

Similar to Responsive Web Design (20)

PDF
Adapt and respond - mobile-friendly layouts beyond the desktop - standards>ne...
PDF
Adaptive layouts - standards>next Manchester 23.03.2011
PDF
Adaptive Layouts - standards>next London 28.05.2011
PDF
The specs behind the sex, mobile-friendly layout beyond the desktop
PDF
Great Responsive-ability Web Design
PDF
Meta layout: a closer look at media queries
PPTX
FITC - 2012-04-23 - Responsive Web Design
PPT
Going Responsive with WordPress
PPTX
Responsive Web Design
PDF
CSS3 Media Queries: Mobile Elixir or CSS Snake Oil
PPTX
Media queries and frameworks
PPTX
Responsive Web Designing for web development
PDF
Intro to @viewport & other new Responsive Web Design CSS features
PDF
Designing for Inclusion with Media Queries: Boston CSS
PPT
Idiot's Guide to viewport and pixel
PDF
Responsive design: techniques and tricks to prepare your websites for the mul...
PDF
Responsive Web Designs
PPT
S. Responsive Web Design
PDF
смартфоны и планшетники. веб разработка помимо десктопа. Patrick h. lauke. зал 1
PPTX
Media Query
Adapt and respond - mobile-friendly layouts beyond the desktop - standards>ne...
Adaptive layouts - standards>next Manchester 23.03.2011
Adaptive Layouts - standards>next London 28.05.2011
The specs behind the sex, mobile-friendly layout beyond the desktop
Great Responsive-ability Web Design
Meta layout: a closer look at media queries
FITC - 2012-04-23 - Responsive Web Design
Going Responsive with WordPress
Responsive Web Design
CSS3 Media Queries: Mobile Elixir or CSS Snake Oil
Media queries and frameworks
Responsive Web Designing for web development
Intro to @viewport & other new Responsive Web Design CSS features
Designing for Inclusion with Media Queries: Boston CSS
Idiot's Guide to viewport and pixel
Responsive design: techniques and tricks to prepare your websites for the mul...
Responsive Web Designs
S. Responsive Web Design
смартфоны и планшетники. веб разработка помимо десктопа. Patrick h. lauke. зал 1
Media Query
Ad

Recently uploaded (20)

PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Cell Types and Its function , kingdom of life
PDF
Basic Mud Logging Guide for educational purpose
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Institutional Correction lecture only . . .
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Cell Types and Its function , kingdom of life
Basic Mud Logging Guide for educational purpose
O7-L3 Supply Chain Operations - ICLT Program
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Insiders guide to clinical Medicine.pdf
Cell Structure & Organelles in detailed.
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Institutional Correction lecture only . . .
Microbial disease of the cardiovascular and lymphatic systems
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Complications of Minimal Access Surgery at WLH
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPH.pptx obstetrics and gynecology in nursing
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...

Responsive Web Design