Responsive Images.

Slides:



Advertisements
Similar presentations
LIS650 lecture 4 Thomas Krichel today Advice CSS Properties –Box properties-- List properties –Table properties-- Classification properties.
Advertisements

LIS650 lecture 4 Thomas Krichel today Advice CSS Properties –Box properties –List properties –Classification properties Fun with selectors.
With CSS, a color is most often specified by: a HEX value - like "#ff0000" an RGB value - like "rgb(255,0,0)" a color name - like "red“ Example h1.
CONCEPTS FOR FLUID LAYOUT Web Page Layout. Website Layouts Most websites have organized their content in multiple columns (formatted like a magazine or.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Tutorial 4 Creating Special Effects with CSS
RESPONSIVE DESIGN Sources: Kadlec, T. (2012). Implementing responsive design. Berkeley, California: New Riders Publishing. MarcotteMarcotte, E. (2010).
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 12: Building Responsive Webpages.
WRA 210 – SS2014 RWD1 : CSS Media Queries. Responsive? Responsive Web Design… Means that a web site works optimally well for users regardless of the device.
WDV 331 Dreamweaver Applications Designing Websites for Mobile Devices Dreamweaver CS6 Chapter 11.
Layouts with CSS Web Design – Section 4-12 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course.
Tutorial 4: Using CSS for Page Layout. 2 Objectives Session 4.1 Explore CSS layout Compare types of floating layouts Examine code for CSS layouts View.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
COMP 135 Web Site Design Intermediate Week 8. Responsive Web Design Responsive Design Adaptive Design.
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
CONCEPTS FOR FLUID LAYOUT Web Page Layout. Website Layouts Most websites have organized their content in multiple columns (formatted like a magazine or.
Interface.  Menu  Document  Insert  Panel Management.
Copyright © Terry Felke-Morris CSS Flow & Positioning 1 Copyright © Terry Felke-Morris.
Copyright 2012 Adobe Systems Incorporated. All rights reserved. ® Copyright 2010 Adobe Systems Incorporated. All rights reserved. ® Copyright 2012 Adobe.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Lesson 05 // Web Design, Layout & Structure 1.Web Design/Designer-Coder Relationship 2.Fixed vs Fluid Website Layouts 3.Screen Resolutions.
Web Design (7) Images (1). Images and the Image Element Images can be placed in the flow of text..jpg,.png and.gif image files work in web pages The img.
Tutorial #6 – Creating Fixed Width Layouts. Tutorial #5 Review – Box Model Every html element is surround by a box Content, Padding, Border, Margin Can.
THE BOX MODEL Putting layouts together with CSS. The Box Model  How would you describe a box?  Container?  Tags or elements are “containers”  puts.
Positioning and Printing Creating Special Effects with CSS.
HTML IMAGES. CONTENTS IMG Tag Alt Attribute Setting Width and Height Of An Image Summary Exercise.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
GO MOBILE. GO RESPONSIVE. 185 mil mobile internet users in India
IN THE DOCUMENT OBJECT MODEL, EACH LINE OF HTML IS AN ELEMENT (AN OBJECT), ABLE TO HAVE ATTRIBUTES, PROPERTIES AND VALUES. CSS TELLS THE BROWSER HOW TO.
04 – CSS Informatics Department Parahyangan Catholic University.
CONCEPTS FOR FLUID LAYOUT Web Page Layout. Essential Questions What challenges do mobile devices present to Web designers? What are the basic concepts.
School of Business Administration
Exploring Computer Science - Lesson 3-4
Cascading Style Sheets Boxes
Implementing Responsive Design
CSS Layouts: Grouping Elements
Exploring Computer Science - Lesson 3-4
A better approach to mobile
Responsive Design and Twitter Bootstrap
Responsive Web Design (RWD)
Concepts for fluid layout
CS 321: Human-Computer Interaction Design
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Introduction to Layouts
Building Responsive Media for Optimal Performance
Web Development & Design Foundations with HTML5 8th Edition
Exploring Computer Science - Lesson 3-4
RESPONSIVE WEB DESIGN.
Web Development & Design Foundations with HTML5 8th Edition
Responsive Design.
Responsive Web Design (RWD)
For the World Wide Web Positioning Objects with CSS
Responsive Web Design (RWD)
Resizing for Projection
Responsive Framework.
Putting An Image on Your Web Page
Cascading Style Sheets™ (CSS)
Responsive Web Design (RWD)
WEB DESIGN FOR MULTIPLE SCREENS
Tutorial 4 Creating Special Effects with CSS
CSS Boxes CS 1150 Fall 2016.
Web Client Side Technologies Raneem Qaddoura
Introduction to Layouts
Web Client Side Technologies Raneem Qaddoura
Concepts for fluid layout
Various mobile devices
Cascading Style Sheets™ (CSS)
17 RESPONSIVE WEB DESIGN.
Presentation transcript:

Responsive Images

A B Approach A max-width or overflow: hidden Approach B <picture>, srcset and sizes

max-width or overflow: hidden The current way

img { width: 100%; height: auto; }

max-width img { max-width: 100%; height: auto; } The image will never get bigger than its container. Can be used on other types of media such as videos and embedded elements.

overflow: hidden div { overflow: hidden } Cuts the image off before it goes outside the container Not ideal unless the image is a pattern or similar

Browser support for max-width and overflow CSS min/max-width/height overflow (visible | hidden | scroll | auto) Browser support for max-width and overflow

<picture>, srcset and sizes B <picture>, srcset and sizes The new way

<picture> The <picture> allows for declaring multiple sources for an image. Its source attributes are used to choose one of the listed images based on different conditions in the browser, and is then fed into the <img>. <picture> <source media=“(min-width: 1000px)” srcset=“large.jpg”> <source media=“(min-width: 780px)” srcset=“medium.jpg”> <img src=“small.jpg”> </picture>

Source attributes srcset sizes media type Specifies the URL of the image to use in different situations. <picture> or <img>. Specifies image sizes for different page layouts. <picture> or <img>. Specifies media queries to determine a source. <picture> required. Specifies a type for the sources given in the srcset attribute. <picture> required.

<picture> srcset and sizes Giving the browser rules it must follow. Providing the browser with information it is missing. We want to let the browser decide on the image as it can optimize better for performance that way while also take user preferences and network connectivity into account.

Use cases Fluid Art direction Pixel ratio Type switch When we have a fluid layout and need our images to resize accordingly. When we want to crop our images differently to fit in with the content. When have images that need to render well at different device-pixel-ratios. When we want to adapt our image format depending on what browsers support them. Fluid Art direction Pixel ratio Type switch

Fluid images - srcset srcset specifies the URL of the image to use. large.jpg (1024 x 768 px) for big screens. medium.jpg (640 x 480 px) for medium screens. small.jpg (320 x 240 px) for small screens. <img srcset=“large.jpg 1024w, medium.jpg 640w, small.jpg 320w”> w descriptors describe the width of the file, in pixels.

Fluid images – sizes sizes tells the browser how many pixels it needs by describing the final desired width of the image within our layout. <img srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w” sizes="(min-width: 36em) 33.3vw, 100vw”> breakpoint vw descriptor stating the % of the width of the container. We want the image to be 33.3% wide. default width that applies if the breakpoint isn’t relevant.

Art direction portrait.jpg (192 × 192 px) landscape.jpg (320 × 240 px) <picture> <source media=“(max-width: 25em)” srcset=“portrait.jpg”> <img src=“landscape.jpg”> </picture> If the screen is smaller than 25em If the screen is bigger than 25em

Pixel ratio small.jpg (320 x 240 px) for low resolution screens. large.jpg (640 x 480 px) for high resolution screens. lower resolution= 1x higher resolution= 2x <img srcset=“small.jpg 1x, large.jpg 2x”> x descriptor stating the device-pixel-ratio that that file is intended for.

Type switch puppy.svg puppy.png puppy.gif <picture> <source type="image/svg" srcset=”puppy.svg”> <source type="image/png" srcset=”puppy.png”> <img src=”puppy.gif”> </picture>

Browser support for <picture> and srcset Picture element Srcset attribute Browser support for <picture> and srcset

Background images background-size: contain 100% 100% cover Image will scale to fit the content area while keeping aspect ratio. Image will stretch to cover the area. Image will scale to cover the are while keeping aspect ratio. Risk for cropping.

Browser support for background-size Background-image options Browser support for background-size