Skip to content

Instantly share code, notes, and snippets.

@ogorzalka
Created November 10, 2010 11:05
Show Gist options
  • Save ogorzalka/670697 to your computer and use it in GitHub Desktop.
Save ogorzalka/670697 to your computer and use it in GitHub Desktop.
it's a fucking hack but it can be useful
// maxheight + maxwidth
img {
/* For good browsers :) */
max-height: 510px;
max-width: 510px;
/* Feed the devil :) */
width: expression(this.offsetWidth>=this.offsetHeight?Math.min(500, this.offsetWidth) : 'auto');
height: expression(this.offsetHeight>this.offsetWidth?Math.min(500, this.offsetHeight) : 'auto');
}
// maxheight
img {
/* For good browsers :) */
max-height: 500px;
/* Feed the devil :) */
height: expression(this.height>510?500:true);
}
// width
img {
/* For good browsers :) */
max-width: 500px;
/* Feed the devil :) */
width: expression(this.width>510?500:true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment