Created
July 28, 2011 13:20
-
-
Save uniquelau/1111527 to your computer and use it in GitHub Desktop.
Get Parent Width, Calculate difference as Percentage
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
$('#nav-1 li .dropdown').each(function(){ | |
var parent_width = (((($(this).width() - $(this).parent().width()) / '2') / $(this).parent().width()) * '100') + ''; | |
var percent_round = Number(parent_width).toFixed(2); | |
$(this).css('margin-left' , '-' + (percent_round) + '%'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment