Skip to content

Instantly share code, notes, and snippets.

@soska
Created December 17, 2009 08:02
Show Gist options
  • Save soska/258613 to your computer and use it in GitHub Desktop.
Save soska/258613 to your computer and use it in GitHub Desktop.
resize images to fit in iPhone viewport
@media:only screen and (max-device-width: 480px){
body{
font-size:14px;
line-height:21px;
padding:10px;
}
img{
max-width:300px;
}
#container{
width:100%;
margin:0;
padding:0;
}
#content{
width:100%;
margin:0;
}
}
jQuery(function($){
$('#content').resize(function(){
var img = $('img',this);
var outWidth = $(this).innerWidth() - 10; // este -10 es faux-padding
img.css({maxWidth:outWidth});
}).resize();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment