I am trying to stop a table with a width explicitly declared not overflowing beyond its parent div . I suppose I can do this with max-width , but I can't get this to work.
The following code (with a very small window) will call the following:
<style type="text/css"> #middlecol { width: 45%; border-right:2px solid red; } #middlecol table { max-width:100% !important; } </style> <div id="middlecol"> <center> <table width="400" cellpadding="3" cellspacing="0" border="0" align="center"> <tr> <td bgcolor="#DDFFFF" align="center" colspan="2"> <strong>Notification!</strong> </td> <tr> <td width="50"> <img src="http://www.example.com/img.png" width="50" height="50" alt="" border="0"> </td> <td> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </td> </tr> </table> </center> </div>
The red line is the right border of the div , and if you make the browser window small, you will see that the table does not fit into it.
html css html-table
waiwai933 Feb 13 '10 at 21:50 2010-02-13 21:50
source share