Created
December 17, 2009 08:02
-
-
Save soska/258613 to your computer and use it in GitHub Desktop.
resize images to fit in iPhone viewport
This file contains 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
@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; | |
} | |
} |
This file contains 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
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