Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created September 13, 2011 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/1214662 to your computer and use it in GitHub Desktop.
Save walterdavis/1214662 to your computer and use it in GitHub Desktop.
<style type="text/css">
<!--
#box p { height:100% }
#box p, #box p img { margin:0; padding:0 }
-->
</style>
$('box').select('img').invoke('writeAttribute','height',null).invoke('writeAttribute','width',null);
var fixPhoto = function(){
var img = $('box').down('img');
var screen = document.viewport.getDimensions();
if(img.getWidth() > screen['width']){
img.setStyle({width: '100%', height: null});
}else{
img.setStyle({height: '100%', width: null});
}
};
fixPhoto();
Event.observe(window,'resize', fixPhoto);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment