Created
July 25, 2017 13:55
-
-
Save 02Tea/f2718ae315bfd269a0211524dd52693f to your computer and use it in GitHub Desktop.
[Dynamic image sizes] #js #jquery
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
$(document).ready(function(){ | |
$('.events__deck > img').each(function(){ | |
$(this).on('load', function(){ | |
var w = $(this).prop("naturalWidth"); | |
var h = $(this).prop("naturalHeight"); | |
var ex = 0.10; | |
// expand images | |
w += w * ex; | |
h += h * ex; | |
$(this).css({"max-width":w + "px", "height":h + "px"}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment