際際滷

際際滷Share 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, dont specify height
and width attributes on images
損 The Key to Responsive Images
img { max-width: 100%; }
 Important: in the HTML, dont specify height
and width attributes on images
 Image renders at the actual dimensions, as
long as its 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, dont specify height
and width attributes on images
 Image renders at the actual dimensions, as
long as its 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 dont 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=/slideshow/responsive-images-fcip-july-2013/24418594/"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=/slideshow/responsive-images-fcip-july-2013/24418594/"/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 its 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=/slideshow/responsive-images-fcip-july-2013/24418594/"js/css3-mediaqueries.js"></script>
<![endif]-->

More Related Content

Similar to Responsive Images FCIP July 2013 (20)

PPT
Responsive Web Design
RZasadzinski
PPTX
Iasi code camp 12 october 2013 responsive images in the wild-vlad zelinschi
Codecamp Romania
PDF
Aaug sample slides
Casandra Calo
PDF
(Practical) Beyond Responsive Web Design (WordCamp Miami 2011)
arborwebsolutions
PPT
Mobile Monday Presentation: Responsive Web Design
Cantina
PDF
Responsive Websites
Joe Seifi
PDF
Retro Responsive: From Fixed-Width to Flexible in 55 Minutes
Rachel Chartoff
PDF
Practical Responsive Images : from Breaking Borders
Ben Seymour
PDF
Responsive Image Strategies
Lindsey Norman
PDF
An Introduction to Responsive Design
Valtech UK
PDF
Deliver perfect images at any size
Anne Thomas
PDF
Deliver Perfect Images At Any Size
FITC
PDF
Sbwire 531031
Tourism Dental India
PDF
Next Steps in Responsive Design
Justin Avery
PPTX
Responsive web design
erikkross
PDF
Responsive web design
Zeeshan Khan
PDF
A Responsive Design Case Study - What We Did Wrong Building ResponsiveDesign....
Aidan Foster
PDF
2022.04 - CSS Day IT - Images Optimisation 4.0
Andrea Verlicchi
PDF
Monkeytalk Fall 2012 - Responsive Web Design
Serge Hufkens
PDF
[html5tx] Adaptive Images in Responsive Web Design
Christopher Schmitt
Responsive Web Design
RZasadzinski
Iasi code camp 12 october 2013 responsive images in the wild-vlad zelinschi
Codecamp Romania
Aaug sample slides
Casandra Calo
(Practical) Beyond Responsive Web Design (WordCamp Miami 2011)
arborwebsolutions
Mobile Monday Presentation: Responsive Web Design
Cantina
Responsive Websites
Joe Seifi
Retro Responsive: From Fixed-Width to Flexible in 55 Minutes
Rachel Chartoff
Practical Responsive Images : from Breaking Borders
Ben Seymour
Responsive Image Strategies
Lindsey Norman
An Introduction to Responsive Design
Valtech UK
Deliver perfect images at any size
Anne Thomas
Deliver Perfect Images At Any Size
FITC
Sbwire 531031
Tourism Dental India
Next Steps in Responsive Design
Justin Avery
Responsive web design
erikkross
Responsive web design
Zeeshan Khan
A Responsive Design Case Study - What We Did Wrong Building ResponsiveDesign....
Aidan Foster
2022.04 - CSS Day IT - Images Optimisation 4.0
Andrea Verlicchi
Monkeytalk Fall 2012 - Responsive Web Design
Serge Hufkens
[html5tx] Adaptive Images in Responsive Web Design
Christopher Schmitt

Recently uploaded (20)

PPTX
Simplifica la seguridad en la nube y la detecci坦n de amenazas con FortiCNAPP
Cristian Garcia G.
PDF
MPU+: A Transformative Solution for Next-Gen AI at the Edge, a Presentation...
Edge AI and Vision Alliance
PDF
Open Source Milvus Vector Database v 2.6
Zilliz
PDF
Scaling i.MX Applications Processors Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
PDF
My Journey from CAD to BIM: A True Underdog Story
Safe Software
PDF
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
PPTX
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
PDF
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
PDF
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
PDF
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
PPTX
Enabling the Digital Artisan keynote at ICOCI 2025
Alan Dix
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
PDF
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
PDF
Database Benchmarking for Performance Masterclass: Session 1 - Benchmarking F...
ScyllaDB
PDF
How to Visualize the Spatio-Temporal Data Using CesiumJS
SANGHEE SHIN
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
Simplifica la seguridad en la nube y la detecci坦n de amenazas con FortiCNAPP
Cristian Garcia G.
MPU+: A Transformative Solution for Next-Gen AI at the Edge, a Presentation...
Edge AI and Vision Alliance
Open Source Milvus Vector Database v 2.6
Zilliz
Scaling i.MX Applications Processors Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
My Journey from CAD to BIM: A True Underdog Story
Safe Software
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
Enabling the Digital Artisan keynote at ICOCI 2025
Alan Dix
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
Database Benchmarking for Performance Masterclass: Session 1 - Benchmarking F...
ScyllaDB
How to Visualize the Spatio-Temporal Data Using CesiumJS
SANGHEE SHIN
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
Ad

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, dont specify height and width attributes on images
  • 5. 損 The Key to Responsive Images img { max-width: 100%; } Important: in the HTML, dont specify height and width attributes on images Image renders at the actual dimensions, as long as its 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, dont specify height and width attributes on images Image renders at the actual dimensions, as long as its 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 dont 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=/slideshow/responsive-images-fcip-july-2013/24418594/"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=/slideshow/responsive-images-fcip-july-2013/24418594/"/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 its 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=/slideshow/responsive-images-fcip-july-2013/24418594/"js/css3-mediaqueries.js"></script> <![endif]-->