Created
December 8, 2016 08:09
-
-
Save sergejmueller/2452451e583b3e33cce58cfa3255c94c to your computer and use it in GitHub Desktop.
Media Queries with dynamically image loading
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 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | |
<title>Your Message Subject or Title</title> | |
<style type="text/css"> | |
.bg { | |
width:300px; | |
height:200px; | |
display: block; | |
} | |
@media all and (max-width: 600px) { | |
.bg { | |
background-image: url('https://dummyimage.com/300x200/000/fff&text=Mobile'); | |
} | |
} | |
@media all and (min-width: 601px) { | |
.bg { | |
background-image: url('https://dummyimage.com/300x200/000/fff&text=Desktop'); | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<table width="100%" border="0" cellspacing="0" cellpadding="0"> | |
<tr><td class="bg"> | |
<!--[if gte mso 9]> | |
<img src="https://dummyimage.com/300x200/000/fff&text=Desktop" width="300" height="200" style="display:block" /> | |
<![endif]--> | |
</td></tr> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment