Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image doesn't render when width and height are defined in percentage with <table> parent element

I'm trying to scale down an image by percentage and this renders correctly in Firefox, but not in Internet Explorer. The img tag needs to be inside a table.

<TABLE>
 <TR>
  <TD>
   <img src="test.gif" width="60%" height="60%">
  </TD>
 </TR>
</TABLE>

Is there a better way to do this so it works in both browsers?

like image 250
Brian Avatar asked Nov 21 '25 14:11

Brian


1 Answers

Try defining the dimensions in CSS instead:

<style type="text/css">
    .myImg{
        width:60%;
        height:60%;
    }
</style>

<table>
 <tr>
  <td>
   <img src="test.gif" class="myImg" />
  </td>
 </tr>
</table>

I don't think some browsers like when you define width/height inline as anything but a numeric value (i.e., width="200");

Anyway, give that a shot - good luck

like image 133
brettkelly Avatar answered Nov 24 '25 02:11

brettkelly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!