Just a question about css for mobile devices,
i have an image that is 1260px wide on my website and when i look at it on the phone it destorts the website as the rest of the website is based on a 960px layout.
I have made these images to be now 960px wide for the mobile device but how do i specify in css that if it is a mobile use mobile optimized image instead of the one on the regular website.
So basically if a user goes on the website on a desktop computer it will show the 1260px image
and if they visit the website on a mobile it will display the 960px image
any ideas guys?
You're looking for media queries. You can write styles conditional on width:
http://webdesignerwall.com/tutorials/responsive-design-with-css3-media-queries
http://www.w3.org/TR/css3-mediaqueries/
Inspired by Ivan's answer, here is a jQuery version that uses media queries to be as close as possible to his CSS3 solution (which doesn't work for me in Firefox 31 and Safari 7):
Im not sure if you want JS, i decided to answer your question if you want CSS3, try this:
HTML:
CSS:
jQuery version: