Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

responsive attribute for HTML/CSS3

View responsive-attr-html5.html
1 2 3 4 5 6 7 8 9 10 11
<!-- backwards compatible solution -->
<!-- the browser should read media-query and then download the right file for the actual screen size -->
<img media-xs="(min-width:640px)" media-xs-src="http://cdn.url.com/img/myimage_xs.jpg" media-m="(max-width:1024px)" media-m-src="http://cdn.url.com/img/myimage_m.jpg" media-xl="(min-width:1025px)" media-xl-src="http://cdn.url.com/img/myimage_xsl.jpg" src="http://cdn.url.com/img/myimage_xs.jpg" />
 
<img media-xs="(max-width:640px)"
media-xs-src="http://cdn.url.com/img/myimage_xs.jpg"
media-m="(max-width:1024px)"
media-m-src="http://cdn.url.com/img/myimage_m.jpg"
media-xl="(min-width:1025px)"
media-xl-src="http://cdn.url.com/img/myimage_xsl.jpg"
src="http://cdn.url.com/img/myimage_xs.jpg" />

Nice idea, I guess you should use "url:()" instead of "use:()" to make it resemble css rules more (like used in 'background-image')

Owner

hm… I'm not sure. Yes, :url() would be more common but it couldn't be clear enough what's menat here. use came into my mind as it's similar to some css3 selectors. But maybe there are more thoughts on it?

Owner

changed code to a better and backwards compatible solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.