Justify Elements Using jQuery and CSS


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $(document).ready(function() {
  2. var max = 0;
  3. $("label").each(function(){
  4. if ($(this).width() > max)
  5. max = $(this).width();
  6. });
  7. $("label").width(max);
  8. });
  9.  
  10. //CSS
  11. label, input[type="text"]{
  12. float:left;
  13. display:block;
  14. }
  15. label
  16. {
  17. margin-right: 5px;
  18. }
  19. .field{
  20. width:100%;
  21. overflow:auto;
  22. margin:5px 0px;
  23. }

URL: http://www.jankoatwarpspeed.com/post/2008/07/09/Justify-elements-using-jQuery-and-CSS.aspx

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.