Skip to content

Instantly share code, notes, and snippets.

@jensgro
Last active August 29, 2015 14:13
Show Gist options
  • Save jensgro/8eb7fa0e63a02fdf7c1f to your computer and use it in GitHub Desktop.
Save jensgro/8eb7fa0e63a02fdf7c1f to your computer and use it in GitHub Desktop.
Die Verwendung des src-set-Attributs
<!-- Bild je nach Pixeldichte (Retina) -->
<img src="bild.jpg"
srcset="bild-2x.jpg 2x"
alt="Tolle Bildbeschreibung">
<!-- Bild je nach Viewportbreite (w = Bildbreite) -->
<img src="small.jpg"
srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w"
alt="Tolle Bildbeschreibung">
<!-- So ist es auch möglich -->
<img
src="http://placehold.it/400x200&text=Fallback"
srcset="http://placehold.it/320x160/ddd 320w,
http://placehold.it/480x240/ccc 480w,
http://placehold.it/768x384/444 768w,
http://placehold.it/1024x512/a20000 1024w,
http://placehold.it/1280x640/fd8700 1280w"
sizes="(max-width: 20em) 100vw,
(max-width: 30em) 60vw,
(max-width: 40em) 50vw"
alt="Super tolle Bildbeschreibung">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment