Top Banner
Responsive layout Joanna Chwastowska, Google
39

Joanna chwastowska responsive layout - droid con

Oct 21, 2014

Download

Software

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Joanna chwastowska   responsive layout - droid con

Responsive layoutJoanna Chwastowska, Google

Page 2: Joanna chwastowska   responsive layout - droid con

● Why

● What

● How

Page 3: Joanna chwastowska   responsive layout - droid con
Page 4: Joanna chwastowska   responsive layout - droid con
Page 5: Joanna chwastowska   responsive layout - droid con
Page 6: Joanna chwastowska   responsive layout - droid con
Page 7: Joanna chwastowska   responsive layout - droid con
Page 8: Joanna chwastowska   responsive layout - droid con
Page 9: Joanna chwastowska   responsive layout - droid con

Mobile specific webpage● maintenance cost

● detecting/redirecting by user agent

● sometimes worth it

● ‘view desktop version’

Page 10: Joanna chwastowska   responsive layout - droid con
Page 11: Joanna chwastowska   responsive layout - droid con
Page 12: Joanna chwastowska   responsive layout - droid con
Page 13: Joanna chwastowska   responsive layout - droid con
Page 14: Joanna chwastowska   responsive layout - droid con

Viewport

● virtual "window"

● usually wider than the screen

● prevent “squeezing”

● users pan and zoom

Page 15: Joanna chwastowska   responsive layout - droid con
Page 16: Joanna chwastowska   responsive layout - droid con

Viewport● usually wider than the screen

● zoom-in for the user

<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">

Page 17: Joanna chwastowska   responsive layout - droid con

Best practices for the new world

● all pages should render legibly on mobile

● write content once, view anywhere

● never show horizontal bar (almost never;)

Page 18: Joanna chwastowska   responsive layout - droid con
Page 19: Joanna chwastowska   responsive layout - droid con
Page 20: Joanna chwastowska   responsive layout - droid con
Page 21: Joanna chwastowska   responsive layout - droid con
Page 22: Joanna chwastowska   responsive layout - droid con

Liquid layout

Page 23: Joanna chwastowska   responsive layout - droid con

Liquid layout

● ability to reflow itself on narrow screen

● never use fixed width/height on containers

● body { max-width: 978px; }.boxout { min-height: 200px; }

Page 24: Joanna chwastowska   responsive layout - droid con

Columns

Page 25: Joanna chwastowska   responsive layout - droid con

Columns

● use % for columns width.column { float: left; margin-right: 2%; width: 32%;}.column.last { margin-right: 0; }

Page 26: Joanna chwastowska   responsive layout - droid con

Scrollbar

Page 27: Joanna chwastowska   responsive layout - droid con

Scrollbar● avoid horizontal scrollbar

● sometimes images / other elements may clog up otherwise liquid layout

img, iframe { max-width: 100%; box-sizing: border-box; }

Page 28: Joanna chwastowska   responsive layout - droid con

Preserve layout

Page 29: Joanna chwastowska   responsive layout - droid con

● always check your content on narrow screen

● make content ‘behave’ by hiding the overflow

.container { overflow: hidden; }

Preserve layout

Page 30: Joanna chwastowska   responsive layout - droid con

Media queries● different use cases for desktop, mobile, and

print● browser support● only styles that differ

@media screen and (max-width: 600px) { /* rules for narrower viewports */ }

Page 31: Joanna chwastowska   responsive layout - droid con

● 978px – desktop and large tabletsmaximum page width; allow full layout and content

● 600px – tabletsKindle Fire and other 7” tablets; adopt two-column layout and drop non-critical content

● 480px – smartphonesone-column layout and mobile specific navigation

Page 32: Joanna chwastowska   responsive layout - droid con

Linearize content

Page 33: Joanna chwastowska   responsive layout - droid con

Linearize contents● narrow columns very hard to read● will not work on IE8 and below

@media screen and (max-width: 480px) { div, li { display: block; float: none; width: 100%; }}

Page 34: Joanna chwastowska   responsive layout - droid con

Navigation

Page 35: Joanna chwastowska   responsive layout - droid con

Navigation● increase hit area, minimum hit area 44px²● no margins, increase padding, linearize

@media screen and (max-width: 480px) { #nav a { display: block; padding: 5px 10px; } }

Page 36: Joanna chwastowska   responsive layout - droid con

Optional content

Page 37: Joanna chwastowska   responsive layout - droid con

Optional content● useful? usable?● dataplans

@media screen and (max-width: 480px) { .optional { display: none; /* not visibility:hidden !*/ } }

Page 39: Joanna chwastowska   responsive layout - droid con

спасибо:)