I have <div>
block that is used for displaying content. I've setup the div so that if the content is to big, a vertical scrollbar should appear.
Now, I need to put table within this container div, and I need it to be as wide as the parent, with a margin of a couple pixels on each side. However, when I apply a margin to the inner-table, the right-side is sizing beyond the edges of the parent div, with the scrollbars.
<div style="overflow: scroll; overflow-x:hidden; position:relative; width: 100%; height:100%; background: magenta">
<table class="data_container" style="width:100%;">
<tr>
<td style="height:400px">How can I fix my margins?</td>
</tr>
</table>
.data_container {
border-color: black;
border-style: solid;
border-width: 2px;
background-color: white;
margin: 50px !important;
font-size: smaller;
}
Also, here is an example of what I'm seeing in JSFiddle. This is a barebones example that demonstrates the problem.