只需要在父级div下添加一个<div style="clear:both;"></div>就可以了
eg:
<div style="height:auto;width:auto;border:dashed;border-color:red">
<div id="main2" style="width:auto;height:500px;float:left"></div>
<div id="table2" style="width:50%;height:100px;border:double;border-color:rebeccapurple;float:right;display:none">
<table>
<thead>
<tr>
<th>项目状态</th>
<th>数量</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div style="clear:both;"></div>
</div>