Posted By

mzym on 09/22/09


Tagged

css jquery lists floats padding justify


Versions (?)

Justify Horizontal Elements


 / Published in: jQuery
 

URL: http://claypool.mzym.biz/justify.php

  1. $(document).ready(function(){
  2. var children = $('#navigation ul li');
  3. var itemSpace = 0;
  4. var itemHeight = 0;
  5. children.each(function(item){
  6. itemSpace += $(this).width();
  7. itemHeight = $(this).height();
  8. });
  9. var margin = Math.floor(($('#navigation').width() - itemSpace) / (children.size() - 1)) - 2;
  10. children.each(function(item){
  11.  
  12. if(item != 0) {
  13. $(this).css('padding-left', margin + 'px' );
  14. }
  15. });
  16. });
  17. });

Report this snippet  

You need to login to post a comment.