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

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

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

Responsive Web Design (RWD) Best Practices Guide Version:

Web Design with CSS and CSS3. Dr. Jan Stelovsky

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

What is CSS? Official W3C standard for controlling presentation Style sheets rely on underlying markup structure

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

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

Building Responsive Layouts

Introduction to Adobe Dreamweaver CC

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

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

IBM Worklight: Responsive Design for Mul8- Channel Applica8on Development

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

JJY s Joomla 1.5 Template Design Tutorial:

Using Style Sheets for Consistency

Web layout guidelines for daughter sites of Scotland s Environment

Contents. Downloading the Data Files Centering Page Elements... 6

Magento Responsive Theme Design

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

{color:blue; font-size: 12px;}

Responsive Web Design. birds of feather

Create Your own Company s Design Theme

Last week we talked about creating your own tags: div tags and span tags. A div tag goes around other tags, e.g.,:

CSS - Cascading Style Sheets

How to Properly Compose HTML Code : 1

We automatically generate the HTML for this as seen below. Provide the above components for the teaser.txt file.

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

Creator Coding Guidelines Toolbox

Outline of CSS: Cascading Style Sheets

Cascading Style Sheets (CSS)

ITNP43: HTML Lecture 4

GUIDE TO CODE KILLER RESPONSIVE S

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

ART 379 Web Design. HTML, XHTML & CSS: Introduction, 1-2

Basics of HTML (some repetition) Cascading Style Sheets (some repetition) Web Design

RESPONSIVE DESIGN FOR MOBILE RENDERING

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

Web Design Revision. AQA AS-Level Computing COMP2. 39 minutes. 39 marks. Page 1 of 17

The Essential Guide to HTML Design

Responsive Design

ICE: HTML, CSS, and Validation

RESPONSIVE DESIGN BY COMMUNIGATOR

Campaign Guidelines and Best Practices

Selectors in Action LESSON 3

Web Design I. Spring 2009 Kevin Cole Gallaudet University

Caldes CM2: Marketing s Support Document v1.12

LaGuardia Community College Thomson Ave, Long Island City, New York Created by ISMD s Dept. Training Team. Overview

8 STEPS TO CODE KILLER RESPONSIVE S

Web Development I & II*

How to Add a Transparent Flash FLV movie to your Web Page Tutorial by R. Berdan Oct

Building Responsive Websites with the Bootstrap 3 Framework

Create Webpages using HTML and CSS

Style & Layout in the web: CSS and Bootstrap

HOW Interactive Design Conference 2013

Web Development 1 A4 Project Description Web Architecture

Responsive Web Design in Application Express

Designing HTML s for Use in the Advanced Editor

Further web design: Cascading Style Sheets Practical workbook

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

Interspire Website Publisher Developer Documentation. Template Customization Guide

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

CSS : petits compléments

Responsive Web Design with HTML5 and CSS3

CREATING RESPONSIVE UI FOR WEB STORE USING CSS

Responsive HTML and Drupal

Joomla! template JSN Mico Customization Manual

CREATING HORIZONTAL NAVIGATION BAR USING ADOBE DREAMWEAVER CS5

File types There are certain image file types that can be used in a web page. They are:

MCH Strategic Data Best Practices Review

WRITE BETTER HTML BY WRITING BETTER CSS

How to craft a modern, mobile-optimized HTML template. Jason Samuels, NCFR IT Manager DrupalCamp Twin Cities May 2012

HTML5 & CSS3. ( What about SharePoint? ) presented

01/42. Lecture notes. html and css

Timeline for Microsoft Dynamics CRM

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

Let's Dig Into the Omega Theme October 27,

Adobe Illustrator CS6. Illustrating Innovative Web Design

Transcription:

HTML Media Types Responsive Web Design: Media Types/Media Queries/Fluid Images Mr Kruyer s list of HTML Media Types to deliver CSS to different devices. Important note: Only the first three are well supported. Examples of HTML <link> method: URL to CSS file <link rel = "stylesheet" href = "path/all-devices.css" media = "all"> This is equivalent to: <link rel = "stylesheet" href = "path/all-devices.css"> <link rel = "stylesheet" href = "path/screen.css" media = "screen"> All types of devices Stylesheet used for: Colour computer monitors <link rel = "stylesheet" href = "path/print.css" media = "print"> Printers <link rel = "stylesheet" href = "path/aural.css" media = "aural"> Webpage readers <link rel = "stylesheet" href = "path/braille-tactile.css" media = "braille"> Webpage to tactile Braille devices <link rel = "stylesheet" href = "path/braille-printer.css" media = "embossed"> Webpage to Braille printers <link rel = "stylesheet" href = "path/handheld.css" media = "handheld"> Handheld devices <link rel = "stylesheet" href = "path/projector.css" media = "projection"> Projectors <link rel = "stylesheet" href = " path/teletype.css" media = "tty"> Teletypes and terminals <link rel = "stylesheet" href = " path/tv.css" media = "tv"> TV devices <link rel = "stylesheet" href = " path/screen.css" media = "screen, tv, projection"> Devices listed using a comma as separator. C:\Users\Kruyer\Documents\TAFE\websiteDevelopment\HTML5\responsive-web-design.docx Page 1

HTML Media Types HTML Media Types Examples of HTML <link> method that includes a media query Stylesheet used for: <link rel = "stylesheet" href = "path/devices.css" media = "(min-width: 10em)"> Devices with minimum width of 10em <link rel = "stylesheet" href = "path/devices.css" media = "(max-width: 90em)"> Devices with maximum width of 90em Example of HTML <link> method for older browsers Stylesheet used for: <!--[if lt IE 9]> <link rel = "stylesheet" href = "path/devices.css"> <![endif]--> Older browsers (in this case IE 9 or older) that do not understand media queries. These browsers get fixed-width layouts. C:\Users\Kruyer\Documents\TAFE\websiteDevelopment\HTML5\responsive-web-design.docx Page 2

CSS 2/3 Media Query rules Mr Kruyer s list of CSS Media Queries for maximum speed to different devices. Examples of CSS 3 @media method Media types Media expressions/(features) Assumed to be all unless specified (color) (monochrome) all (min-width: 20em) screen (max-width: 30em) print (orientation: portrait) (orientation: landscape) (device-width: 480px) Notes: 1/ Older browsers recognise media types so do not use these if you do not want the query to be applied. 2/ Hide styles from non CSS 3 browsers using keyword: any @media all and (color) This is equivalent to: @media (color) @media screen and (color) and, not only Only understood by devices with modern browsers. Older browsers ignore these. They refer to viewport size, colour capabilities orientation etc. These four keywords are used to join multiple expressions. Note:, = or CSS code applied to: All types of devices that support colour. Your CSS rules would only be applied to modern browsers. Only colour computer monitors. Your CSS rules would be applied to both modern and older browsers. C:\Users\Kruyer\Documents\TAFE\websiteDevelopment\HTML5\responsive-web-design.docx Page 3

@media screen and (color: 256) @media (min-width: 20em) and (max-width: 30em) @media (min-width: 20em), (orientation: landscape) @media not (orientation: portrait) @media only screen and (min-width: 20em) /* Place your CSS 3 rules here */ @media any and (max-width: 320px) and (orientation: portrait) /* Place your CSS 3 rules here */ Only supports computer monitors with 256 colours. CSS rules would be applied to both modern and older browsers. All types of devices that have a minimum width of 20em and maximum width of 30em. Applied to modern browsers only. All types of devices that have a minimum width of 20em or screen in landscape mode. Applied to modern browsers only. All types of devices that are not in portrait mode. Applied to modern browsers only. Only computer monitors that have min. width of 20em (Useful when blocking older browsers that don t support media features.) Any device that has max. width of 320px and screen in portrait mode. (Useful when blocking older browsers that don t support media features.) @media (min-width: 20em) and (max-width: 30em) @media (min-width: 30.01em) and (max-width: 40em) @media (min-width: 40.01em) and (max-width: 50em) @media (min-width: 50.01em) and (max-width: 60em) @media (min-width: 60.01em) All types of devices delivering five different CSS rules depending on the minimum width and maximum width of the device. C:\Users\Kruyer\Documents\TAFE\websiteDevelopment\HTML5\responsive-web-design.docx Page 4

CSS 2: Images @media (min-width: 700px) body font-size: 120%; @media (min-width: 800px) body font-size: 140%; @media (min-width: 900px) body font-size: 160%; @media (min-width: 1000px) body font-size: 180%; @media (min-width: 1100px) body font-size: 200%; All types of devices delivering five overlapping (increasing) font sizes depending on the (increasing) width of the device. Mr Kruyer s table for delivering fluid foreground/background images using CSS CSS code for fluid inline or background images /* For fluid inline image use the following four properties/values: */ img max-width: 100%; vertical-align: middle; border: 0; image-rendering: optimizequality; CSS lines explained: 1. Image can be reduced but never larger than original size. 2. Image centred within the line of surrounding text. 3. Removes blue image border of older browsers. 4. Improves image quality for Firefox. (Use optimizespeed lower quality but faster loading.) C:\Users\Kruyer\Documents\TAFE\websiteDevelopment\HTML5\responsive-web-design.docx Page 5

CSS 3: Backgrounds /* Background cropped on left and right with height constant: */.responsive-crop-bg-image width: 100%; height: 300px; background-image: url(../images/pic.jpg); background-size: cover; background-position: center center; background-repeat: no-repeat; contain scales image keeping aspect ratio to fit inside area. cover scales image keeping aspect ratio to cover area. Clipping can occur. Clipping does not happen in the second CSS background image rule as the boxheight (i.e. bottom padding) is set to maintain the background image aspect ratio. /* Background scaled maintaining aspect ratio: */.responsive-scalable-bg-image width: 100%; padding-bottom: 50%; background-image: url(../images/pic.jpg); background-size: cover; background-position: center center; background-repeat: no-repeat; Notes: 1/ Tiling can occur if the image height or width is fixed unless background-repeat: no-repeat; is included. 2/ Aspect ratio = 50% For my pic.jpg image: Height = 300px Width = 600px 300/600 = 50%.container max-width: 600px; margin: 0 auto; border: 1px solid red; C:\Users\Kruyer\Documents\TAFE\websiteDevelopment\HTML5\responsive-web-design.docx Page 6

The HTML code for the above CSS 3 code: Screen dumps: <div class = "container"> <h1>fluid background images</h1> <p>the container's maximum width is set to 600 pixels and has a 1 pixel red border.</p> <div class = "responsive-crop-bg-image"></div> <p>this top background image will have the left and right sides cropped when the webpage is resized down. When scaled up the image</p> <div class = "responsive-scalable-bg-image"></div> <p>this second background image will scale down with the aspect ratio maintained when the webpage is resized down.</p> </div> Before scaling down: webpage width > 600px After scaling down: webpage width < 600px C:\Users\Kruyer\Documents\TAFE\websiteDevelopment\HTML5\responsive-web-design.docx Page 7