Posted By

Jamie on 11/20/09


Tagged

width images


Versions (?)

Scale Images Down to Fit a Column


 / Published in: JavaScript
 

  1. var maxWidth = 320;
  2. var adjustmentSet = document.getElementById('col-main').getElementsByTagName('img');
  3. for (var i=0; i < adjustmentSet.length; i++) {
  4. if(adjustmentSet[i].width > maxWidth){
  5. adjustmentSet[i].removeAttribute('height');
  6. adjustmentSet[i].style.width = '100%';
  7. }
  8. }

Report this snippet  

You need to login to post a comment.