Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Forked from necolas/css-responsive-images.html
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save dongyuwei/90dbc36cc946cd1b5632 to your computer and use it in GitHub Desktop.

Select an option

Save dongyuwei/90dbc36cc946cd1b5632 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS responsive images</title>
<style>
/* Play nice with existing requirements for
Responsive Images polyfill */
@media screen and (min-device-width:600px) {
img[src*=".r."] {
content: attr(data-src-600px, url);
}
}
@media screen and (min-device-width:800px) {
img[src*=".r."] {
content: attr(data-src-800px, url);
}
}
</style>
</head>
<body>
<img src="image.r.jpg"
data-src-600px="image-600px.jpg"
data-src-800px="image-800px.jpg"
alt="">
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS responsive images</title>
<style>
@media screen and (min-device-width:600px) {
img {
content: attr(data-src-600px, url);
}
}
@media screen and (min-device-width:800px) {
img {
content: attr(data-src-800px, url);
}
}
</style>
</head>
<body>
<img src="image.jpg"
data-src-600px="image-600px.jpg"
data-src-800px="image-800px.jpg"
alt="">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment