Last active
August 29, 2015 13:56
-
-
Save AllThingsSmitty/9278895 to your computer and use it in GitHub Desktop.
An example of how to implement the <picture> element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Picture Element</title> | |
<style> | |
@media all { | |
#pictureElement { | |
background-image: image-set(small-1.jpg 1x, small-2.jpg 2x); | |
} | |
} | |
@media all and (min-width: 45em){ | |
#pictureElement{ | |
background-image: image-set(large-1.jpg 1x, large-2.jpg 2x); | |
} | |
} | |
@media all and (min-width: 18em){ | |
#pictureElement{ | |
background-image: image-set(med-1.jpg 1x, med-2.jpg 2x); | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<picture id="pictureElement"> | |
<source media="(min-width: 45em)" srcset="large-1.jpg 1x, large-2.jpg 2x"> | |
<source media="(min-width: 18em)" srcset="med-1.jpg 1x, med-2.jpg 2x"> | |
<!-- assume media all --> | |
<source srcset="small-1.jpg 1x, small-2.jpg 2x"> | |
<!-- the following are ignored --> | |
<source media=" is the message " srcset=""> | |
</picture> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment