Is possible to override the body width, for example I have this ex.:
<body>
<table id="table1">
<tr><td></td></tr>
</table>
<table id="table2">
<tr><td></td></tr>
</table>
</body>
css:
body{width:970px;}
#table1{width:100%;}
#table2{width:100%;}
I want to set for first table a width:auto; expandable on full browser width but body width won’t allow.
I must have that body:970px so I cannot modify that and I must have 100% for second table to expand all elements inside in 970px body width.
how do I resolve this ?
There is no good way to do this; HTML elements always inherit attributes from their parents. So if you give
bodya fixed width, you essentially limit what the children can do. For them, the world (i.e.width: 100%) is now the limitedbodywidth and there is no way to say “use the parent width but skip the body element, please”.With JavaScript, you could try to get the width of the
htmlelement but even if you assigned this totable1, the overflow rules would probably clip it.To fix this, you will have to get rid of the fixed body width. Replace body with a container
divwith a fixed width. That allows you to movetable1outside the containerdivwhere it will see thebody‘s natural width.