Building Responsive Layouts



Similar documents
You can use percentages for both page elements and text. Ems are used for text,

Going Beyond SAP ITS Mobile Apps to a Responsive Design Mobile Apps. JK (JayaKumar Pedapudi) Principal Consultant NTT DATA, Inc.

Responsive Web Design: Media Types/Media Queries/Fluid Images

Viewports. Peter-Paul Koch jquery EU, 28 February 2014

Principles of Web Design 6 th Edition. Chapter 12 Responsive Web Design

Different Screen Size, Different Design

Responsive Web Design (RWD) Best Practices Guide Version:

CREATING RESPONSIVE UI FOR WEB STORE USING CSS

Web Design Basics. Cindy Royal, Ph.D. Associate Professor Texas State University

Responsive Web Design for Drupal

Responsive Web Design (RWD) Building a single web site for the desktop, tablet and smartphone

This document will describe how you can create your own, fully responsive. drag and drop template to use in the creator.

Outline of CSS: Cascading Style Sheets

Responsive and Adaptive Web Design. Responsive & Adaptive websites-respond to the user s device by showing an optimized view.

Responsive Web Design. birds of feather

Web layout guidelines for daughter sites of Scotland s Environment

Responsive Web Design for Teachers. Exercise: Building a Responsive Page with the Fluid Grid Layout Feature

Building Responsive Websites with the Bootstrap 3 Framework

Why? Mobile. 0Your content is no more than 3 taps away from Angry Birds. 0 Many people access your website via smartphones and other mobile devices

Web Publishers Group. Tuesday 13 March 2012

Chapter 8 More on Links, Layout, and Mobile Key Concepts. Copyright 2013 Terry Ann Morris, Ed.D

8 STEPS TO CODE KILLER RESPONSIVE S

Web Design and Development ACS Chapter 9. Page Structure

Using Style Sheets for Consistency

Style & Layout in the web: CSS and Bootstrap

Chapter 7 Page Layout Basics Key Concepts. Copyright 2013 Terry Ann Morris, Ed.D

Mobile Web Design with HTML5, CSS3, JavaScript and JQuery Mobile Training BSP-2256 Length: 5 days Price: $ 2,895.00

Responsive Web Design with HTML5 and CSS3

Responsive Web Design for Libraries: Beyond the Mobile Web

Responsive Design: Ben Callahan

DESIGNING MOBILE FRIENDLY S

Responsive Web Design

JJY s Joomla 1.5 Template Design Tutorial:

Recommendations for Websites Optimization for Mobile Devices Using Mobile Centric CSS. February 2014 Update

Treble: One Page Website. Step 8 - Responsive Web Design

Magento Responsive Theme Design

GUIDE TO CODE KILLER RESPONSIVE S

White Paper Using PHP Site Assistant to create sites for mobile devices

ICE: HTML, CSS, and Validation

Web Design with CSS and CSS3. Dr. Jan Stelovsky

Drupal theming using the 960.gs grid system

Web Design I. Spring 2009 Kevin Cole Gallaudet University

CSS for Page Layout. Key Concepts

Responsive Web Design in Application Express

Coding HTML Tips, Tricks and Best Practices

Responsive Design Best Practices

IBM Worklight: Responsive Design for Mul8- Channel Applica8on Development

CST 150 Web Design I CSS Review - In-Class Lab

THE SAS OUTPUT DELIVERY SYSTEM: BOLDLY TAKE YOUR WEB PAGES WHERE THEY HAVE NEVER GONE BEFORE! CHEVELL PARKER, SAS INSTITUTE INC.

Responsive Design

CSS 101. CSS CODE The code in a style sheet is made up of rules of the following types

1 of 8 9/14/2011 5:40 PM

PLAYER DEVELOPER GUIDE

Essential HTML & CSS for WordPress. Mark Raymond Luminys, Inc mraymond@luminys.com

Let's Dig Into the Omega Theme October 27,

BEYOND RESPONSIVE. by Marcus Morba (drupal.org/user/ = mori) Sunday 24 November 13

1. About the Denver LAMP meetup group. 2. The purpose of Denver LAMP meetups. 3. Volunteers needed for several positions

HTML CSS Basic Structure. HTML Structure [Source Code] CSS Structure [Cascading Styles] DIV or ID Tags and Classes. The BOX MODEL

How to Properly Compose HTML Code : 1

Responsive Design for

Designing HTML ers

Responsive Design How to get started

The Essential Guide to HTML Design

Fast track to HTML & CSS 101 (Web Design)

Web Browser. Fetches/displays documents from web servers. Mosaic 1993

WEB DEVELOPMENT IA & IB (893 & 894)

HOW Interactive Design Conference 2013

Advanced Online Media Dr. Cindy Royal Texas State University - San Marcos School of Journalism and Mass Communication

Intro to Web Design. ACM UIUC

Introduction to Adobe Dreamweaver CC

Designing CSS Layouts for the Flexible Web. July 18, 2009 The CSS Summit Zoe Mickley Gillenwater

With mobile devices and tablets becoming popular for browsing the web, an increasing number of websites are turning to responsive designs to

Pay with Amazon Integration Guide

Web Design and Databases WD: Class 7: HTML and CSS Part 3

RESPONSIVE DESIGN

Creator Coding Guidelines Toolbox

Building Your First Drupal 8 Company Site

RESPONSIVE DESIGN BY COMMUNIGATOR

Web Development I & II*

Responsive Web Design Creative License

Optimizing Sites for Mobile Devices

Designing HTML s for Use in the Advanced Editor

HTML5 & CSS3. ( What about SharePoint? ) presented

Mobile Optimise your s. Code & examples to make your campaigns mobile friendly

Slicing and Coding the Navigation Background in CSS

Designing Web Sites for Phone Browsers

Campaign Guidelines and Best Practices

RESPONSIVE DESIGN FOR MOBILE RENDERING

Slide.Show Quick Start Guide

jquery Tutorial for Beginners: Nothing But the Goods

Table of Contents Find out more about NewZapp

CIS 467/602-01: Data Visualization

CREATING A NEWSLETTER IN ADOBE DREAMWEAVER CS5 (step-by-step directions)

Website Planning Checklist

Responsive website design for higher education utilizing mobile centric features

Web Development CSE2WD Final Examination June (a) Which organisation is primarily responsible for HTML, CSS and DOM standards?

Web Development 1 A4 Project Description Web Architecture

Web Design & Development - Tutorial 04

ios App Development Using Cordova

Extended Reference for Freeway 7

Transcription:

Building Responsive Layouts by Zoe Mickley Gillenwater @zomigi August 28, 2012 Responsive Web Design Summit

What I do Books Stunning CSS3: A Project-based Guide to the Latest in CSS www.stunningcss3.com Flexible Web Design: Creating Liquid and Elastic Layouts with CSS www.flexiblewebbook.com Web Accessibility specialist at AT&T Visual designer CSS developer and consultant 2

why responsive web design works 3

what why responsive web design means 4

what why? how to do responsive web design 5

fluid/liquid layout uses percentage widths to adapt to size of viewport 6

hybrid layout one+ column flexible, one+ not 7

responsive web design fluid layout and flexible images adapted with media queries www.alistapart.com/articles/responsive-web-design/ 8

adaptive layouts multiple fixed-width layouts swapped with media queries www.netmagazine.com/tutorials/adaptive-layouts-media-queries 9

Look at this! This is so tough! I'm in such peril way up here! 10

Oh, wait 11

How do we make this fluid? 12

Start with fluid wrapper 13

Add opposing floats inside 14

3-column layout: nest 2-column layout inside 2-column layout 15

Percentages are relative 16

Determining nested widths width of column you want to match width of parent column = width of nested column 17

Determining nested widths width of column you want to match width of parent column = width of nested column target context = result 18

Determining nested widths width of column you want to match width of parent column = width of nested column target context = result 20 80 =.25 which means 25% 19

That's more like it 20

What about fluid grids? 21

Width of this nested block? 22

Well that's not right 23

To the laboratory! width of column you want to match width of parent column = width of nested column target context = result 25 62.5 =.4 which means 40% 24

There we go 25

widths? spacing between and in fluid columns 26

Leave a gap via widths 27

Declaring fluid margin/padding Adjust widths so everything adds up to just under 100% Avoids problems due to rounding % to px Nesting affects margin/padding values too Use target/context formula to match outer spacing with inner spacing 28

Using box-sizing Makes fixed-width margin/padding on fluid layout easy Standard box model box-sizing: content-box Padding & border added on to width/height New box model box-sizing: border-box Padding & border subtracted from width/height 29

Fluid grid, fixed-width spacing.column { float: left; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding: 0 20px; } 30

Use border as faux margin.column { float: left; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding: 0 20px; border-left: 10px solid rgba(0,0,0,0); -moz-background-clip: padding-box; -webkit-background-clip: padding-box; background-clip: padding-box; }.row { margin-left: -10px; } 31

Fix box-sizing in IE 7 and 6 Feed different dimensions based on content-box-model, or Use Christian Schaefer's box-sizing polyfill https://github.com/schepp/box-sizing-polyfill.column { box-sizing: border-box; *behavior: url(boxsizing.htc); } 32

I recommend gridpak.com 33

fluid? hybrid main column fluid, sidebar fixed 34

Hybrid layout options Easy: sidebars first in HTML Float sidebars, main content moves up between floats But usually not option in responsive design Tricky: main content first in HTML Need to float it, but with what width? One solution: negative margins 35

Fixed-width sidebar starting point 36

Add wrapper with padding #content-wrapper { padding-right: 290px; } 37

Lay out main content div #content-main { float: left; width: 100%; } 38

Float sidebar #content-secondary { float: right; width: 250px; } 39

A positive right margin 150px 40

A negative right margin -150px 41

Add negative right margin matching wrapper's right padding #content-secondary { float: right; width: 250px; margin-right: -290px; } 42

Success! 43

To make sidebar show in IE 6 #content-wrapper { zoom: 1; } #content-main, #content-secondary { display: inline; } 44

3-column hybrid layout Nest one 2-column layout inside another Components of each layout: 1. Wrapper with padding on one side 2. Fixed-width sidebar Same width as padding (or smaller) Floated same direction as padding Negative margin matching padding on same side 3. Fluid column Floated opposite direction Width 100% 45

fluid layout? media queries feed different styles based on viewport size 46

Choosing default styles Start "mobile," layer on wider styles? Start "desktop," layer on narrower styles? Start somewhere in between, layer on both? Learn full pros/cons: www.zomigi.com/blog/essential-considerationscrafting-quality-media-queries 47

Starting in the middle 48

Wide-screen media query /*all the other styles up here*/ @media screen and (min-width: 1200px) { /*styles for larger screens in here*/ } 49

Add third column @media screen and (min-width: 1200px) { #nav-main { position: fixed; top: 136px; width: 13%; margin: 0; } #content-main { width: 58%; margin-left: 18%; } #content-secondary { width: 20%; } } 50

Style nav as vertical menu @media screen and (min-width: 1200px) {... #nav-main li { float: none; margin: 0; } #nav-main a { -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; } } 51

Wide-screen design 52

Small-screen media query /*all the other styles up here*/ @media screen and (max-width: 760px) { /*styles for smaller screens in here*/ } 53

Things to fix too few words per line, so make all one column each too narrow, so stack instead and put pic on left 54

Narrowscreen design 55

Mobile media query /*all the other styles up here*/ @media screen and (max-width: 550px) { /*styles for tiny screens in here*/ } 56

Non-overlapping version @media screen and (min-width: 551px) and (max-width: 760px) { /*styles for small screens in here*/ } @media screen and (max-width: 550px) { /*styles for tiny screens in here*/ } 57

Changing to single column @media screen and (max-width: 550px) { #content-main, #content-secondary, #about, #credits { float: none; width: 100%; } } 58

Changing feature images @media screen and (max-width: 550px) {....feature { padding-left: 70px; } #feature-candy { background-image: url(icon_candy_64.png); } #feature-pastry { background-image: url(icon_pastry_64.png); } #feature-dessert { background-image: url(icon_dessert_64.png); } } 59

Mobile design 60

Viewport meta tag Forces mobile devices to scale viewport to actual device width <meta name="viewport" content="width=device-width"> 61

Zoom problem in ios The device-width on ios devices always matches portrait width This means design doesn't reflow when you switch to landscape, but instead just zooms 62

Fixing (and adding) zoom issues Option 1: add maximum-scale=1 But disables user scaling <meta name="viewport" content="width=device-width, maximum-scale=1"> Option 2: add initial-scale=1 Allows user scaling But triggers over-zoom/crop bug when changing from portrait to landscape <meta name="viewport" content="width=device-width, initial-scale=1"> 63

The best way to fix zoom issues Option 3: add initial-scale=1 plus script to fix over-zoom bug See http://filamentgroup.com/lab/a_fix_for_ the_ios_orientationchange_zoom_bug/ <head>... <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="ios-orientationchange-fix.js">... </head> 64

conditional comments or JavaScript to deal with IE 8 and earlier 65

Conditional comments Split styles into separate sheets and feed applicable sheet to IE based on whether it's IE on desktop or mobile Approach varies based on which set of styles are your default 66

Conditional comment when desktop styles are default Feed IE Mobile 7 media query sheet: <link rel="stylesheet" href="global.css" media="all"> <link rel="stylesheet" href="mobile.css" media="all and (max-width: 700px)"> <!--[if IEMobile 7]> <link rel="stylesheet" href="mobile.css" media="all"> <![endif]--> Source: http://blogs.msdn.com/b/iemobile/archive/2010/12/08/targeting-mobileoptimized-css-at-windows-phone-7.aspx 67

Conditional comment when mobile styles are default Feed older IE media query sheet, hide from IE Mobile 7: <link rel="stylesheet" href="global.css" media="all"> <link rel="stylesheet" href="desktop.css" media="all and (min-width: 700px)"> <!--[if (lt IE 9)&(!IEMobile 7)]> <link rel="stylesheet" href="desktop.css" media="all"> <![endif]--> Source: http://adactio.com/journal/4494/ 68

Pre-fab JavaScript for nonsupporting browsers Simply add one of these scripts: Respond: https://github.com/scottjehl/respond css3-mediaqueries.js: http://code.google.com/p/css3-mediaqueries-js/ Avoid extra HTTP request for non-old-ie browsers using conditional comments: <!--[if (lt IE 9)&(!IEMobile 7)]> <script src="respond.min.js"></script> <![endif]--> 69

View it live http://stunningcss3.com/code/bakery/ 70

Learn more Download slides and get links at http://zomigi.com/blog/responsive-layoutspresentation Zoe Mickley Gillenwater @zomigi design@zomigi.com zomigi.com stunningcss3.com flexiblewebbook.com Title photo by Steve James (http://www.flickr.com/photos/steeljam/3350481764/) Rock climbing photo by Justin Johnson (http://www.flickr.com/photos/justinjohnsen/4512815628/) 71