Hi there Rain Lover,
if you check the table offsetWidth with javascript, you will see that it has a width of 3022px.
Setting the div container width to 100% is pointless as that is it's default width.
It must be set to the table width.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
<style type="text/css">
div {width:3022px;}
table, td {border:1px solid #000;}
td {width:1000px;}
</style>
<script type="text/javascript">
function init(){
alert('overall table width='
+document.getElementsByTagName('table')[0].offsetWidth+'px');
}
window.addEventListener?
window.addEventListener('load',init,false):
window.attachEvent('onload',init);
</script>
</head>
<body>
<div>
<table>
<tr>
<td>First cell</td>
<td>Second cell</td>
<td>Third cell</td>
</tr>
<tr>
<td>Forth cell</td>
<td>Fifth cell</td>
<td>Sixth cell</td>
</tr>
</table>
</div>
</body>
</html>
coothead
Bookmarks