Created
October 25, 2015 06:46
-
-
Save Niloys7/ea54d5e7351da34d8656 to your computer and use it in GitHub Desktop.
Get Equal Width for element base on parent element
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
var total = 0; | |
$('.ClassName').each(function() { | |
total+= $(this).width(); | |
total+= parseInt($(this).css('margin-left'), 0); | |
total+= parseInt($(this).css('margin-right'), 0); | |
total+= 0; | |
}); | |
var num_blocks = $('.ClassName').size(); | |
// now calculate the extra space left | |
var extra_space = (parseInt($('.ParentClassName').width())-total)/num_blocks; | |
$('.tt_tabs li').each(function() { | |
$(this).width($(this).width()+Math.floor(extra_space)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment