Visma CMS Adding negative margin-top depends on number of TR tag


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

Depends on the number of tr tag, it will add a negative margin-top except less than 15


Copy this code and paste it in your HTML
  1. $(document).ready(function() {
  2. var len = $('#infoinner tr').size();
  3. if (len>15 && len<50){
  4. var roundlen = Math.round(len*1.5);
  5. }
  6. else if (len>50 && len<75){
  7. var roundlen = Math.round(len*2.4);
  8. }
  9. else if (len>75 && len<100){
  10. var roundlen = Math.round(len*3.6);
  11. }
  12. else if (len>100 && len<150)
  13. {
  14. var roundlen = Math.round(len*4.8);
  15. }else if (len>150 && len<200)
  16. {
  17. var roundlen = Math.round(len*6);
  18. }else
  19. {
  20. var roundlen = Math.round(len*7);
  21. }
  22. if(len<15)
  23. {
  24. var margintop = '0';
  25. $('#infoinner table').css('margin-top',margintop);
  26.  
  27. }else{
  28. var margintop = '-'+ roundlen +'px';
  29. }
  30. $('#infoinner').css('margin-top',margintop);
  31.  
  32. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.