Created
March 30, 2016 08:39
-
-
Save zazanik/57e693ecc9f6d7138c740ce9333fb051 to your computer and use it in GitHub Desktop.
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
<div class="container test"> | |
<img src="http://placehold.it/100x100" class="flex-item" alt="" /> | |
<img src="http://placehold.it/100x100" class="flex-item" alt="" /> | |
<img src="http://placehold.it/100x100" class="flex-item" alt="" /> | |
</div> | |
$(window).load(function(){ | |
/ Stuff to do after the page is loaded / | |
$conteinerWidth = $(".test").width(); | |
$flexItem = $(".test .flex-item").length; | |
$totalItemWidth = 0; | |
$(".flex-item").each(function(index, el) { | |
$totalItemWidth += el.width; | |
}); | |
$emptyWidth = $conteinerWidth - $totalItemWidth | |
$flexItem +=1 | |
$margin = $emptyWidth / $flexItem; | |
$marginSUPER = $margin; | |
$margin /=2; | |
console.log($margin +" $margin"); | |
$(".flex-item").css({"margin": $margin}); | |
$(".flex-item").first().css({"marginLeft": $marginSUPER}); | |
$(".flex-item").last().css({"marginRight": $marginSUPER}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment