SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
RESPONSIVE WEB
DESIGN
Logan Chien
AGENDA
Introduction
Foundation of RWD
Retrospective
INTRODUCTION
WHAT IS RWD?1/4
Responsive Web Design is a methodology which advocates
one HTML file should be able to adapt to different screen
size.
WHAT IS RWD?2/4
screenshot with 1400x800 resolutionThe Next Web
WHAT IS RWD?3/4
screenshot with 1024px and 320px widthThe Next Web
WHAT IS RWD?4/4
1
2
3 4
1
2 3 4
1
2
3
4
Large Medium Small
Desktop Phone
MOTIVATION
Too many screen resolutions — width, height, and dpi
Difficult to determine screen size from user agent
FOUNDATION OF RWD
VIEW PORT1/2
Viewport is a rectangular area that is being viewed.
On mobile devices, the default width is usually larger than
the actual screen size.
To build a mobile-friendly website, we should explicitly
specify width=device‑width.
< m e t a n a m e = " v i e w p o r t "
c o n t e n t = " w i d t h = d e v i c e - w i d t h , i n i t i a l - s c a l e = 1 . 0 " / >
VIEW PORT2/2
Name Description Value
width Viewport width Integer in pixels or device‑width
minimum-
scale
Minimum possible zoom
scale
Floating point between 0.0 — 10.0
maximum-
scale
Maximum possible zoom
scale
Floating point between 0.0 — 10.0
initial-
scale
Initial scale when the
page is loaded
Floating point between minimum‑scale
and maximum‑scale
user-
scalable
Can user zoom in/out? yesor no
CSS MEDIA QUERY
@ m e d i a o n l y s c r e e n a n d ( m a x - w i d t h : 5 0 0 p x ) {
/ * A p p l i e s w h e n w i d t h i s l e s s t h a n o r e q u a l t o 5 0 0 p x . * /
}
@ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 5 0 0 p x ) {
/ * A p p l i e s w h e n w i d t h i s g r e a t e r t h a n o r e q u a l t o 5 0 0 p x . * /
}
CSS MEDIA QUERY DETAILS 1/3
@ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 5 0 0 p x )
a n d ( m a x - w i d t h : 1 2 0 0 p x ) {
/ * A p p l i e s w h e n w i d t h i s i n 5 0 0 - 1 2 0 0 p x . * /
}
keyword only— No special effect on new browsers. Old
browsers will completely ignore the media query directive.
media type — all, screen, and print
CSS MEDIA QUERY DETAILS 2/3
@ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 5 0 0 p x )
a n d ( m a x - w i d t h : 1 2 0 0 p x ) {
/ * R u l e s f o r s c r e e n s w i t h 5 0 0 - 1 2 0 0 p x v i e w p o r t w i d t h . * /
}
MEDIA FEATURES
prefix — min, max
viewport — width, height, aspect‑ratio
device — device‑width, device‑height, device‑aspect‑
ratio
CSS MEDIA QUERY DETAILS 3/3
p { c o l o r : b l u e ; }
@ m e d i a o n l y s c r e e n a n d ( m a x - w i d t h : 7 6 8 p x ) {
p { t e x t - d e c o r a t i o n : u n d e r l i n e ; }
}
@ m e d i a o n l y s c r e e n a n d ( m a x - w i d t h : 3 2 0 p x ) {
p { b a c k g r o u n d - c o l o r : y e l l o w ; }
}
768px < width hello
320 < width<=768px hello
width<=320px hello
GRID AND FLUID
Use percentage instead of absolute measure units
Use grids to organize the content
33% 33% 33% 50% 50% 100%
100%
Control with CSS media query
MOBILE FIRST
/ * C S S r u l e s f o r m o b i l e c o m e s f i r s t . * /
@ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 3 2 1 p x ) {
/ * C S S r u l e s f o r t a b l e t o r l a r g e r d e v i c e s . * /
}
@ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 1 0 2 4 p x ) {
/ * C S S r u l e s f o r d e s k t o p . * /
}
Reason: Some assets for desktop require a lot of network
bandwidth, which is undesired for mobile. Thus, it will be
preferred to give priority to mobile.
RANGE OVERLAP 1/2
. m e d i u m - o n l y { d i s p l a y : n o n e ; }
. l a r g e - o n l y { d i s p l a y : n o n e ; }
@ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 3 2 0 p x ) {
. m e d i u m - o n l y { d i s p l a y : i n l i n e ; }
}
@ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 5 0 0 p x ) {
. m e d i u m - o n l y { d i s p l a y : n o n e ; } / * r e s e t * /
. l a r g e - o n l y { d i s p l a y : i n l i n e ; }
}
This style sheet resets the CSS property when the screen size
is larger than the desired width.
RANGE OVERLAP 2/2
. m e d i u m - o n l y { d i s p l a y : n o n e ; }
. l a r g e - o n l y { d i s p l a y : n o n e ; }
@ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 3 2 0 p x ) a n d ( m a x - w i d t h : 4 9 9 p x ) {
. m e d i u m - o n l y { d i s p l a y : i n l i n e ; }
}
@ m e d i a o n l y s c r e e n a n d ( m a x - w i d t h : 5 0 0 p x ) {
. l a r g e - o n l y { d i s p l a y : i n l i n e ; }
}
Off-by-one is necessary, otherwise both will be available on
500px.
This style sheet uses exclusive media query, but this might
fail when the screen size is between 499px and 500px.
IMAGE AND PICTURE
<img>tag with srcsetand sizesattributes
<picture>tag with <source>tags and a fallback <img>tag
<IMG>, SRCSET, AND SIZES
< i m g a l t = " p l a c e h o l d e r "
s r c = " s m a l l . p n g "
s r c s e t = " l a r g e . p n g 1 2 0 0 w , m e d i u m . p n g 5 0 0 w , s m a l l . p n g 3 2 0 w "
s i z e s = " ( m i n - w i d t h : 8 0 0 p x ) 4 0 v w , 1 0 0 v w " / >
srcset — specifies 3 images large.png, medium.png, and
small.pngfor screen that are larger than 1200px, 500px, and
320px respectively.
size — specifies 2 sizes. If the screen size is larger than or
equal to 800px, then resize image to 40% of the screen size.
Otherwise, fit the image to the screen.
<PICTURE> AND <SOURCE>
< p i c t u r e >
< s o u r c e m e d i a = " ( m i n - w i d t h : 8 0 0 p x ) "
s r c s e t = " l a r g e . j p g 1 0 2 4 w , m e d i u m . j p g 5 0 0 w , s m a l l . j p g 3 2 0 w "
s i z e s = " ( m i n - w i d t h : 1 2 0 0 p x ) 3 0 v w , 4 0 v w " / >
< s o u r c e s r c s e t = " c r o p p e d - l a r g e . j p g 2 x , c r o p p e d - s m a l l . j p g 1 x " / >
< i m g s r c = " s m a l l . j p g " a l t = " p l a c e h o l d e r " / >
< / p i c t u r e >
Remarks. <source>can refers to non-equivalent images (i.e.
browsers might not be able to derive one from the other
with resizing algorithms.)
RETROSPECTIVE
IE SUPPORT
IE 6-8 does not have CSS media query support.
An severe issue on mobile first website.
There is a shim layer named written in
Javascript.
Respond.js
Guideline: Degrade the QoS gracefully even with mobile-
based CSS.
ONE SIZE DON'T FIT ALL
RWD is suboptimal because the users have to download
some unused content/asset. However, properly cra ed site
can mitigate the overhead.
RWD is not the answer to every questions. A good design
should be designed. A good mobile website requires not only
a responsive layout but also well-studied mobile use cases.
CONCLUSION
RWD is a technique for web pages to adjust itself on
different screen sizes.
Use CSS media query to support different screen sizes.
Use srcset, sizes, or even pictureto load different
source images.
RWD is the trend but mobile use case analyses are still
required.
THE END
Q & A

Contenu connexe

Dernier

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Dernier (20)

MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 

En vedette

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Responsive Web Design

  • 4. WHAT IS RWD?1/4 Responsive Web Design is a methodology which advocates one HTML file should be able to adapt to different screen size.
  • 5. WHAT IS RWD?2/4 screenshot with 1400x800 resolutionThe Next Web
  • 6. WHAT IS RWD?3/4 screenshot with 1024px and 320px widthThe Next Web
  • 7. WHAT IS RWD?4/4 1 2 3 4 1 2 3 4 1 2 3 4 Large Medium Small Desktop Phone
  • 8. MOTIVATION Too many screen resolutions — width, height, and dpi Difficult to determine screen size from user agent
  • 10. VIEW PORT1/2 Viewport is a rectangular area that is being viewed. On mobile devices, the default width is usually larger than the actual screen size. To build a mobile-friendly website, we should explicitly specify width=device‑width. < m e t a n a m e = " v i e w p o r t " c o n t e n t = " w i d t h = d e v i c e - w i d t h , i n i t i a l - s c a l e = 1 . 0 " / >
  • 11. VIEW PORT2/2 Name Description Value width Viewport width Integer in pixels or device‑width minimum- scale Minimum possible zoom scale Floating point between 0.0 — 10.0 maximum- scale Maximum possible zoom scale Floating point between 0.0 — 10.0 initial- scale Initial scale when the page is loaded Floating point between minimum‑scale and maximum‑scale user- scalable Can user zoom in/out? yesor no
  • 12. CSS MEDIA QUERY @ m e d i a o n l y s c r e e n a n d ( m a x - w i d t h : 5 0 0 p x ) { / * A p p l i e s w h e n w i d t h i s l e s s t h a n o r e q u a l t o 5 0 0 p x . * / } @ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 5 0 0 p x ) { / * A p p l i e s w h e n w i d t h i s g r e a t e r t h a n o r e q u a l t o 5 0 0 p x . * / }
  • 13. CSS MEDIA QUERY DETAILS 1/3 @ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 5 0 0 p x ) a n d ( m a x - w i d t h : 1 2 0 0 p x ) { / * A p p l i e s w h e n w i d t h i s i n 5 0 0 - 1 2 0 0 p x . * / } keyword only— No special effect on new browsers. Old browsers will completely ignore the media query directive. media type — all, screen, and print
  • 14. CSS MEDIA QUERY DETAILS 2/3 @ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 5 0 0 p x ) a n d ( m a x - w i d t h : 1 2 0 0 p x ) { / * R u l e s f o r s c r e e n s w i t h 5 0 0 - 1 2 0 0 p x v i e w p o r t w i d t h . * / } MEDIA FEATURES prefix — min, max viewport — width, height, aspect‑ratio device — device‑width, device‑height, device‑aspect‑ ratio
  • 15. CSS MEDIA QUERY DETAILS 3/3 p { c o l o r : b l u e ; } @ m e d i a o n l y s c r e e n a n d ( m a x - w i d t h : 7 6 8 p x ) { p { t e x t - d e c o r a t i o n : u n d e r l i n e ; } } @ m e d i a o n l y s c r e e n a n d ( m a x - w i d t h : 3 2 0 p x ) { p { b a c k g r o u n d - c o l o r : y e l l o w ; } } 768px < width hello 320 < width<=768px hello width<=320px hello
  • 16. GRID AND FLUID Use percentage instead of absolute measure units Use grids to organize the content 33% 33% 33% 50% 50% 100% 100% Control with CSS media query
  • 17. MOBILE FIRST / * C S S r u l e s f o r m o b i l e c o m e s f i r s t . * / @ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 3 2 1 p x ) { / * C S S r u l e s f o r t a b l e t o r l a r g e r d e v i c e s . * / } @ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 1 0 2 4 p x ) { / * C S S r u l e s f o r d e s k t o p . * / } Reason: Some assets for desktop require a lot of network bandwidth, which is undesired for mobile. Thus, it will be preferred to give priority to mobile.
  • 18. RANGE OVERLAP 1/2 . m e d i u m - o n l y { d i s p l a y : n o n e ; } . l a r g e - o n l y { d i s p l a y : n o n e ; } @ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 3 2 0 p x ) { . m e d i u m - o n l y { d i s p l a y : i n l i n e ; } } @ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 5 0 0 p x ) { . m e d i u m - o n l y { d i s p l a y : n o n e ; } / * r e s e t * / . l a r g e - o n l y { d i s p l a y : i n l i n e ; } } This style sheet resets the CSS property when the screen size is larger than the desired width.
  • 19. RANGE OVERLAP 2/2 . m e d i u m - o n l y { d i s p l a y : n o n e ; } . l a r g e - o n l y { d i s p l a y : n o n e ; } @ m e d i a o n l y s c r e e n a n d ( m i n - w i d t h : 3 2 0 p x ) a n d ( m a x - w i d t h : 4 9 9 p x ) { . m e d i u m - o n l y { d i s p l a y : i n l i n e ; } } @ m e d i a o n l y s c r e e n a n d ( m a x - w i d t h : 5 0 0 p x ) { . l a r g e - o n l y { d i s p l a y : i n l i n e ; } } Off-by-one is necessary, otherwise both will be available on 500px. This style sheet uses exclusive media query, but this might fail when the screen size is between 499px and 500px.
  • 20. IMAGE AND PICTURE <img>tag with srcsetand sizesattributes <picture>tag with <source>tags and a fallback <img>tag
  • 21. <IMG>, SRCSET, AND SIZES < i m g a l t = " p l a c e h o l d e r " s r c = " s m a l l . p n g " s r c s e t = " l a r g e . p n g 1 2 0 0 w , m e d i u m . p n g 5 0 0 w , s m a l l . p n g 3 2 0 w " s i z e s = " ( m i n - w i d t h : 8 0 0 p x ) 4 0 v w , 1 0 0 v w " / > srcset — specifies 3 images large.png, medium.png, and small.pngfor screen that are larger than 1200px, 500px, and 320px respectively. size — specifies 2 sizes. If the screen size is larger than or equal to 800px, then resize image to 40% of the screen size. Otherwise, fit the image to the screen.
  • 22. <PICTURE> AND <SOURCE> < p i c t u r e > < s o u r c e m e d i a = " ( m i n - w i d t h : 8 0 0 p x ) " s r c s e t = " l a r g e . j p g 1 0 2 4 w , m e d i u m . j p g 5 0 0 w , s m a l l . j p g 3 2 0 w " s i z e s = " ( m i n - w i d t h : 1 2 0 0 p x ) 3 0 v w , 4 0 v w " / > < s o u r c e s r c s e t = " c r o p p e d - l a r g e . j p g 2 x , c r o p p e d - s m a l l . j p g 1 x " / > < i m g s r c = " s m a l l . j p g " a l t = " p l a c e h o l d e r " / > < / p i c t u r e > Remarks. <source>can refers to non-equivalent images (i.e. browsers might not be able to derive one from the other with resizing algorithms.)
  • 24. IE SUPPORT IE 6-8 does not have CSS media query support. An severe issue on mobile first website. There is a shim layer named written in Javascript. Respond.js Guideline: Degrade the QoS gracefully even with mobile- based CSS.
  • 25. ONE SIZE DON'T FIT ALL RWD is suboptimal because the users have to download some unused content/asset. However, properly cra ed site can mitigate the overhead. RWD is not the answer to every questions. A good design should be designed. A good mobile website requires not only a responsive layout but also well-studied mobile use cases.
  • 26. CONCLUSION RWD is a technique for web pages to adjust itself on different screen sizes. Use CSS media query to support different screen sizes. Use srcset, sizes, or even pictureto load different source images. RWD is the trend but mobile use case analyses are still required.