在您的代碼中,您不需要關閉<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