在您的代码中,您不需要关闭<td>
's,而是每个都在关闭</tr>
中终止。如果在<td>
没有内容,添加
表行(<tr>
)将默认为表的100%,如果除去display: inline-block
,并正确终止它们。把它们包裹起来,让它们浮起来。这使您有机会为表格添加标题或添加控件。
我建议的HTML:
<div class="wrapper">
<div class="left">
<table id="table1">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</div>
<div class="right">
<table id="table2">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</div>
</div>
CSS:
的所有代码
/* Optionally throw in a media query, so the floats only happen if there is enough room for the two tables next to each other, but seamlessly fall under each other if not -- @media screen and (min-width: 600px){*/
.left{float:left; width:50%;}
.right{float:right; width:50%;}
/* } Optionally, close the media query here. */
/* Keep the wrapper open until both tables are done*/
.wrapper:after{clear:both;}
table{}
/* Add margin if the tables get to close, or negative margin if you want them closer*/
为什么你元素与关闭? –
糟糕,修正了这个问题。 – ghadams