SlideShare a Scribd company logo
»
Responsive ImagesResponsive Images
Fort Collins Internet ProfessionalsFort Collins Internet Professionals
July 18, 2013July 18, 2013
» Goal 1: Scaling Images
» Goal 1: Scaling Images
• Auto-scaling
• as viewport is resized
• for different devices (different screen widths)
» The Key to Responsive Images
img { max-width: 100%; }
• Important: in the HTML, don’t specify height
and width attributes on images
» The Key to Responsive Images
img { max-width: 100%; }
• Important: in the HTML, don’t specify height
and width attributes on images
• Image renders at the actual dimensions, as
long as it’s narrower than its containing
element
• Modern browsers rock– they resize images
proportionally, aspect ratio remains intact
» The Key to Responsive Images
img { max-width: 100%; }
• Important: in the HTML, don’t specify height
and width attributes on images
• Image renders at the actual dimensions, as
long as it’s narrower than its containing
element
• Modern browsers rock– they resize images
proportionally, aspect ratio remains intact
• Bonus: works for embed, video, and object
too
» Implementation Example
img { max-width: 100%; }
img.responsive-31 { width:31%;}
http://www.frameworkstimber.com/
> About > Stewardship
» Goal 2: Responsible Images
» Goal 2: Responsible Images
• AKA – Treat your children well
• Respect the bandwidth issues of your mobile
visitors
– Slower download speeds (in many cases)
– May be paying by the bit! (in $ome cases)
» The Situation
• Want to use images with small file sizes for
mobile visitors
• Want to serve beautiful high-res images with
larger file sizes to those with 3000px displays
• But, whatever you do you don’t want mobile
devices to be downloading any more images
than necessary
• How?
» One Technique: picturefill.js
• Scott Jehl
• https://github.com/scottjehl/picturefill
• A Responsive Images approach that mimics
the proposed picture element. More info:
– http://usecases.responsiveimages.org/
– Use cases and requirements for standardizing
responsive images, under development by the
Responsive Image Community Group
» One Technique: picturefill.js
<span data-picture data-alt="A giant stone face at The
Bayon temple in Angkor Thom, Cambodia">
<span data-src="small.jpg"></span>
<span data-src="medium.jpg" data-media="(min-width:
400px)"></span>
<span data-src="large.jpg" data-media="(min-width:
800px)"></span>
<span data-src="extralarge.jpg" data-media="(min-
width: 1000px)"></span>
<!-- Fallback content for non-JS browsers. Same img
src as the initial, unqualified source element. -->
<noscript>
<img src="external/imgs/small.jpg" alt="A giant
stone face at The Bayon temple in Angkor Thom,
Cambodia">
</noscript>
</span>
» An Implemenation
• Home page background image for
frameworkstimber.com
» An implementation
<div data-picture data-alt="Frameworks Timber - Timber Framing" id="home-background">
<div data-src="/wp-content/themes/fwt/images/home-background-600-n1.jpg"></div>
<div data-src="/wp-content/themes/fwt/images/home-background-800-n1.jpg" data-
media="(min-width: 601px) and (max-width: 800px)"></div>
<div data-src="/wp-content/themes/fwt/images/home-background-1200m.jpg" data-
media="(min-width: 801px) and (max-width: 1200px)"></div>
<div data-src="/wp-content/themes/fwt/images/home-background-1500m.jpg" data-
media="(min-width: 1201px) and (max-width: 1500px)"></div>
<div data-src="/wp-content/themes/fwt/images/home-background-2000m.jpg" data-
media="(min-width: 1501px) and (max-width: 2000px)"></div>
<div data-src="/wp-content/themes/fwt/images/home-background-5000.jpg" data-
media="(min-width: 2001px)"></div>
<!--[if (lte IE 9) & (!IEMobile)]>
<div data-src="/wp-content/themes/fwt/images/home-background-2000m.jpg"></div>
<![endif]-->
<noscript>
<img src="/wp-content/themes/fwt/images/home-background-600.jpg"
alt="Frameworks Timber - Timber Framing">
</noscript>
</div>
» Span vs. Div
• You may have noticed that the Jehl example
uses spans and my example uses divs.
• v1 of picturefill.js uses divs
• Newer versions use spans for a few reasons,
one of which is that since the <img> tag is an
inline element by default, <span> is a better
fit as it’s also an inline element compared
with <div> which is a block element.
» Additional Resources
• The article that started it all, by Ethan Marcotte:
– http://www.alistapart.com/articles/responsive-web-design/
• Fluid Images by Ethan Marcotte:
– http://unstoppablerobotninja.com/entry/fluid-images
• IE8 and below Media Queries fix:
– http://code.google.com/p/css3-mediaqueries-js/
• IE6 min/max-width hack:
– http://www.cameronmoll.com/archives/000892.html
• Fluid Grids by Ethan Marcotte:
– http://www.alistapart.com/articles/fluidgrids/
• Media Queries reference, list of Media Query selectors available:
– http://www.w3.org/TR/css3-mediaqueries/
• Responsive Typesetting:
– http://www.alistapart.com/d/responsive-web-design/ex/ex-article.html
» Where to find me
• @ron_z – follow me on Twitter
• ronz@codegeek.net
• codegeek.net
• IgniteFortCollins.com and @IgniteFC
• The Fort Collins Hive: HiveFC.com
»
Thank YouThank You
Fort Collins Internet ProfessionalsFort Collins Internet Professionals
July 18, 2013July 18, 2013
» Media Queries?
First, Media Types, which you already know:
<link rel="stylesheet" media="screen" href="c.css" />
<link rel="stylesheet" media=”print" href="c.css" />
» CSS3 Media Queries
In your HTML:
<link rel="stylesheet"
media="screen and (max-width:340px)” href=“c.css” />
Or more commonly, in your CSS:
@media screen and (max-width:340px) { Styles applicable
for viewports 340px and narrower … }
» CSS3 Media Queries
• min-width (refers to viewport dimensions)
• min-device-width refers to display dimensions
of the device (maybe safe for identifying the
device, iPad, iPhone, etc.)
• can select based on dpi or dpcm, not just
width
• can select based on color depth
» More Media Queries
http://www.w3.org/TR/css3-mediaqueries/
• width
• height
• device-width
• device-height
• orientation
• aspect-ratio
• device-aspect-ratio
• color
• color-index
• monochrome
• resolution
• scan
• grid
» Browser Support
• Opera 9.5+
• Firefox 3.5+
• Safari 3+
• Chrome
• IE9 +
• Mobile Webkit
• Opera Mobile ~
» A magic bullet
code.google.com/p/css3-mediaqueries-js/
• IE5 – IE8
• Firefox 1 & 2
• Safari 2
• Legacy, if you only care about IE5 – IE8:
<!--[if lt IE 9]>
<script type="text/javascript" src="js/css3-mediaqueries.js"></script>
<![endif]-->

More Related Content

Similar to Responsive Images FCIP July 2013

Advancio, Inc. Academy: Responsive Web Design
Advancio, Inc. Academy: Responsive Web DesignAdvancio, Inc. Academy: Responsive Web Design
Advancio, Inc. Academy: Responsive Web Design
Advancio
 
Responsive websites. Toolbox
Responsive websites. ToolboxResponsive websites. Toolbox
Responsive websites. Toolbox
Wojtek Zając
 
[SF HTML5] Responsive Cross-Device Development with Web Standards (2013)
[SF HTML5] Responsive Cross-Device Development with Web Standards (2013)[SF HTML5] Responsive Cross-Device Development with Web Standards (2013)
[SF HTML5] Responsive Cross-Device Development with Web Standards (2013)
Tomomi Imura
 
There Is No Mobile: An Introduction To Responsive Web Design
There Is No Mobile: An Introduction To Responsive Web DesignThere Is No Mobile: An Introduction To Responsive Web Design
There Is No Mobile: An Introduction To Responsive Web Design
Chris Love
 
Responsive Web Design - Web & PHP Conference - 2013-09-18
Responsive Web Design - Web & PHP Conference - 2013-09-18Responsive Web Design - Web & PHP Conference - 2013-09-18
Responsive Web Design - Web & PHP Conference - 2013-09-18
Frédéric Harper
 
Great Responsive-ability Web Design
Great Responsive-ability Web DesignGreat Responsive-ability Web Design
Great Responsive-ability Web Design
Mike Wilcox
 
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin..."Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
Yandex
 
Rwd slidedeck
Rwd slidedeckRwd slidedeck
Rwd slidedeck
Vera Kovaleva
 
Responsive Web Design tips and tricks.
Responsive Web Design tips and tricks.Responsive Web Design tips and tricks.
Responsive Web Design tips and tricks.
GaziAhsan
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
Ben MacNeill
 
FITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive ImagesFITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive Images
Rami Sayar
 
FITC - 2012-04-23 - Responsive Web Design
FITC - 2012-04-23 - Responsive Web DesignFITC - 2012-04-23 - Responsive Web Design
FITC - 2012-04-23 - Responsive Web DesignFrédéric Harper
 
Successfully implementing open graph by steve mortiboy
Successfully implementing open graph by steve mortiboySuccessfully implementing open graph by steve mortiboy
Successfully implementing open graph by steve mortiboy
Steve Mortiboy
 
(Practical) Beyond Responsive Web Design (WordCamp Miami 2011)
(Practical) Beyond Responsive Web Design (WordCamp Miami 2011)(Practical) Beyond Responsive Web Design (WordCamp Miami 2011)
(Practical) Beyond Responsive Web Design (WordCamp Miami 2011)
arborwebsolutions
 
UX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentations
UX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentationsUX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentations
UX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentations
UX Alive Conference
 
Node.js 101
 Node.js 101 Node.js 101
Node.js 101
FITC
 
OSCAL: Free and Open Source Tools for Image and Video Performance
OSCAL: Free and Open Source Tools for Image and Video PerformanceOSCAL: Free and Open Source Tools for Image and Video Performance
OSCAL: Free and Open Source Tools for Image and Video Performance
Doug Sillars
 
5 Steps To Deliver The Fastest Mobile Shopping Experience This Holiday Season
5 Steps To Deliver The Fastest Mobile Shopping Experience This Holiday Season5 Steps To Deliver The Fastest Mobile Shopping Experience This Holiday Season
5 Steps To Deliver The Fastest Mobile Shopping Experience This Holiday Season
G3 Communications
 
2022.04 - CSS Day IT - Images Optimisation 4.0
2022.04 - CSS Day IT - Images Optimisation 4.02022.04 - CSS Day IT - Images Optimisation 4.0
2022.04 - CSS Day IT - Images Optimisation 4.0
Andrea Verlicchi
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and Techniques
Vitaly Friedman
 

Similar to Responsive Images FCIP July 2013 (20)

Advancio, Inc. Academy: Responsive Web Design
Advancio, Inc. Academy: Responsive Web DesignAdvancio, Inc. Academy: Responsive Web Design
Advancio, Inc. Academy: Responsive Web Design
 
Responsive websites. Toolbox
Responsive websites. ToolboxResponsive websites. Toolbox
Responsive websites. Toolbox
 
[SF HTML5] Responsive Cross-Device Development with Web Standards (2013)
[SF HTML5] Responsive Cross-Device Development with Web Standards (2013)[SF HTML5] Responsive Cross-Device Development with Web Standards (2013)
[SF HTML5] Responsive Cross-Device Development with Web Standards (2013)
 
There Is No Mobile: An Introduction To Responsive Web Design
There Is No Mobile: An Introduction To Responsive Web DesignThere Is No Mobile: An Introduction To Responsive Web Design
There Is No Mobile: An Introduction To Responsive Web Design
 
Responsive Web Design - Web & PHP Conference - 2013-09-18
Responsive Web Design - Web & PHP Conference - 2013-09-18Responsive Web Design - Web & PHP Conference - 2013-09-18
Responsive Web Design - Web & PHP Conference - 2013-09-18
 
Great Responsive-ability Web Design
Great Responsive-ability Web DesignGreat Responsive-ability Web Design
Great Responsive-ability Web Design
 
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin..."Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
 
Rwd slidedeck
Rwd slidedeckRwd slidedeck
Rwd slidedeck
 
Responsive Web Design tips and tricks.
Responsive Web Design tips and tricks.Responsive Web Design tips and tricks.
Responsive Web Design tips and tricks.
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 
FITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive ImagesFITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive Images
 
FITC - 2012-04-23 - Responsive Web Design
FITC - 2012-04-23 - Responsive Web DesignFITC - 2012-04-23 - Responsive Web Design
FITC - 2012-04-23 - Responsive Web Design
 
Successfully implementing open graph by steve mortiboy
Successfully implementing open graph by steve mortiboySuccessfully implementing open graph by steve mortiboy
Successfully implementing open graph by steve mortiboy
 
(Practical) Beyond Responsive Web Design (WordCamp Miami 2011)
(Practical) Beyond Responsive Web Design (WordCamp Miami 2011)(Practical) Beyond Responsive Web Design (WordCamp Miami 2011)
(Practical) Beyond Responsive Web Design (WordCamp Miami 2011)
 
UX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentations
UX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentationsUX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentations
UX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentations
 
Node.js 101
 Node.js 101 Node.js 101
Node.js 101
 
OSCAL: Free and Open Source Tools for Image and Video Performance
OSCAL: Free and Open Source Tools for Image and Video PerformanceOSCAL: Free and Open Source Tools for Image and Video Performance
OSCAL: Free and Open Source Tools for Image and Video Performance
 
5 Steps To Deliver The Fastest Mobile Shopping Experience This Holiday Season
5 Steps To Deliver The Fastest Mobile Shopping Experience This Holiday Season5 Steps To Deliver The Fastest Mobile Shopping Experience This Holiday Season
5 Steps To Deliver The Fastest Mobile Shopping Experience This Holiday Season
 
2022.04 - CSS Day IT - Images Optimisation 4.0
2022.04 - CSS Day IT - Images Optimisation 4.02022.04 - CSS Day IT - Images Optimisation 4.0
2022.04 - CSS Day IT - Images Optimisation 4.0
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and Techniques
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 

Responsive Images FCIP July 2013

  • 1. » Responsive ImagesResponsive Images Fort Collins Internet ProfessionalsFort Collins Internet Professionals July 18, 2013July 18, 2013
  • 2. » Goal 1: Scaling Images
  • 3. » Goal 1: Scaling Images • Auto-scaling • as viewport is resized • for different devices (different screen widths)
  • 4. » The Key to Responsive Images img { max-width: 100%; } • Important: in the HTML, don’t specify height and width attributes on images
  • 5. » The Key to Responsive Images img { max-width: 100%; } • Important: in the HTML, don’t specify height and width attributes on images • Image renders at the actual dimensions, as long as it’s narrower than its containing element • Modern browsers rock– they resize images proportionally, aspect ratio remains intact
  • 6. » The Key to Responsive Images img { max-width: 100%; } • Important: in the HTML, don’t specify height and width attributes on images • Image renders at the actual dimensions, as long as it’s narrower than its containing element • Modern browsers rock– they resize images proportionally, aspect ratio remains intact • Bonus: works for embed, video, and object too
  • 7. » Implementation Example img { max-width: 100%; } img.responsive-31 { width:31%;} http://www.frameworkstimber.com/ > About > Stewardship
  • 8. » Goal 2: Responsible Images
  • 9. » Goal 2: Responsible Images • AKA – Treat your children well • Respect the bandwidth issues of your mobile visitors – Slower download speeds (in many cases) – May be paying by the bit! (in $ome cases)
  • 10. » The Situation • Want to use images with small file sizes for mobile visitors • Want to serve beautiful high-res images with larger file sizes to those with 3000px displays • But, whatever you do you don’t want mobile devices to be downloading any more images than necessary • How?
  • 11. » One Technique: picturefill.js • Scott Jehl • https://github.com/scottjehl/picturefill • A Responsive Images approach that mimics the proposed picture element. More info: – http://usecases.responsiveimages.org/ – Use cases and requirements for standardizing responsive images, under development by the Responsive Image Community Group
  • 12. » One Technique: picturefill.js <span data-picture data-alt="A giant stone face at The Bayon temple in Angkor Thom, Cambodia"> <span data-src="small.jpg"></span> <span data-src="medium.jpg" data-media="(min-width: 400px)"></span> <span data-src="large.jpg" data-media="(min-width: 800px)"></span> <span data-src="extralarge.jpg" data-media="(min- width: 1000px)"></span> <!-- Fallback content for non-JS browsers. Same img src as the initial, unqualified source element. --> <noscript> <img src="external/imgs/small.jpg" alt="A giant stone face at The Bayon temple in Angkor Thom, Cambodia"> </noscript> </span>
  • 13. » An Implemenation • Home page background image for frameworkstimber.com
  • 14. » An implementation <div data-picture data-alt="Frameworks Timber - Timber Framing" id="home-background"> <div data-src="/wp-content/themes/fwt/images/home-background-600-n1.jpg"></div> <div data-src="/wp-content/themes/fwt/images/home-background-800-n1.jpg" data- media="(min-width: 601px) and (max-width: 800px)"></div> <div data-src="/wp-content/themes/fwt/images/home-background-1200m.jpg" data- media="(min-width: 801px) and (max-width: 1200px)"></div> <div data-src="/wp-content/themes/fwt/images/home-background-1500m.jpg" data- media="(min-width: 1201px) and (max-width: 1500px)"></div> <div data-src="/wp-content/themes/fwt/images/home-background-2000m.jpg" data- media="(min-width: 1501px) and (max-width: 2000px)"></div> <div data-src="/wp-content/themes/fwt/images/home-background-5000.jpg" data- media="(min-width: 2001px)"></div> <!--[if (lte IE 9) & (!IEMobile)]> <div data-src="/wp-content/themes/fwt/images/home-background-2000m.jpg"></div> <![endif]--> <noscript> <img src="/wp-content/themes/fwt/images/home-background-600.jpg" alt="Frameworks Timber - Timber Framing"> </noscript> </div>
  • 15. » Span vs. Div • You may have noticed that the Jehl example uses spans and my example uses divs. • v1 of picturefill.js uses divs • Newer versions use spans for a few reasons, one of which is that since the <img> tag is an inline element by default, <span> is a better fit as it’s also an inline element compared with <div> which is a block element.
  • 16. » Additional Resources • The article that started it all, by Ethan Marcotte: – http://www.alistapart.com/articles/responsive-web-design/ • Fluid Images by Ethan Marcotte: – http://unstoppablerobotninja.com/entry/fluid-images • IE8 and below Media Queries fix: – http://code.google.com/p/css3-mediaqueries-js/ • IE6 min/max-width hack: – http://www.cameronmoll.com/archives/000892.html • Fluid Grids by Ethan Marcotte: – http://www.alistapart.com/articles/fluidgrids/ • Media Queries reference, list of Media Query selectors available: – http://www.w3.org/TR/css3-mediaqueries/ • Responsive Typesetting: – http://www.alistapart.com/d/responsive-web-design/ex/ex-article.html
  • 17. » Where to find me • @ron_z – follow me on Twitter • ronz@codegeek.net • codegeek.net • IgniteFortCollins.com and @IgniteFC • The Fort Collins Hive: HiveFC.com
  • 18. » Thank YouThank You Fort Collins Internet ProfessionalsFort Collins Internet Professionals July 18, 2013July 18, 2013
  • 19. » Media Queries? First, Media Types, which you already know: <link rel="stylesheet" media="screen" href="c.css" /> <link rel="stylesheet" media=”print" href="c.css" />
  • 20. » CSS3 Media Queries In your HTML: <link rel="stylesheet" media="screen and (max-width:340px)” href=“c.css” /> Or more commonly, in your CSS: @media screen and (max-width:340px) { Styles applicable for viewports 340px and narrower … }
  • 21. » CSS3 Media Queries • min-width (refers to viewport dimensions) • min-device-width refers to display dimensions of the device (maybe safe for identifying the device, iPad, iPhone, etc.) • can select based on dpi or dpcm, not just width • can select based on color depth
  • 22. » More Media Queries http://www.w3.org/TR/css3-mediaqueries/ • width • height • device-width • device-height • orientation • aspect-ratio • device-aspect-ratio • color • color-index • monochrome • resolution • scan • grid
  • 23. » Browser Support • Opera 9.5+ • Firefox 3.5+ • Safari 3+ • Chrome • IE9 + • Mobile Webkit • Opera Mobile ~
  • 24. » A magic bullet code.google.com/p/css3-mediaqueries-js/ • IE5 – IE8 • Firefox 1 & 2 • Safari 2 • Legacy, if you only care about IE5 – IE8: <!--[if lt IE 9]> <script type="text/javascript" src="js/css3-mediaqueries.js"></script> <![endif]-->