Monday 19 November 2012

How to Convert width from percentage to pixels

 Formula to calculate width in Pixels from percentage.


var pixels = parentWidth*(percents/100);

Example: 
Let suppose Outer container having width 420px and Outer Container has a table having width = 100%
Now you want to assign width of td's in pixels so use this formula to calculate.

  Pixels = 420*(16 /100); 

 <div style='width:420px;'> 
      <table style='width:100%;'> 
           <tr> 
              <td></td>
              <td></td>
              <td></td>
              <td></td>
           </tr>
      </table>
  </div>
 

No comments:

Post a Comment