Skip to content

Instantly share code, notes, and snippets.

@jordancalder
Created October 14, 2013 06:10
Show Gist options
  • Save jordancalder/6971483 to your computer and use it in GitHub Desktop.
Save jordancalder/6971483 to your computer and use it in GitHub Desktop.
js replace
jQuery(document).ready(function () {
jQuery(".imgResize").on('load', function () {
var $this = jQuery(this);
if ($this.width() > $this.height()) {
$this.addClass("landscape");
} else if ($this.width() < $this.height()) {
$this.addClass("portrait");
} else {
}
var $h = $this.height();
$this.css('margin-top', +$h / -2 + "px");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment