假设我在Div中包含了2张桌子:
<div class = "main" id = "mainDiv">
<table id = "one">
1
</table>
<table id = "two">
2
</table>
</div>
如何将这两个表并排显示,彼此间隔5 px? 是否有像#34; cellspacing&#34;我可以用于桌子吗?
答案 0 :(得分:1)
你的结构不正确,它应该是这样的:
<div class = "main" id = "mainDiv">
<table id = "one">
<tr>
<td>1</td>
</tr>
</table>
<table id = "two">
<tr>
<td>2</td>
</tr>
</table>
</div>
您可以将表格的display:table;
更改为display:inline-table;
,以便将它们对齐在一行上。
答案 1 :(得分:0)
我会使用css,你可以使它响应,查看2列的代码。在此代码中,它是2个相等宽度的列,为49.2%。如果你想要一个不同的拆分更改。
/* SECTIONS */
.section {
clear: both;
padding: 0px;
margin: 0px;
}
/* COLUMN SETUP */
.col {
display: block;
float:left;
margin: 1% 0 1% 1.6%;
}
.col:first-child { margin-left: 0; }
/* GROUPING */
.group:before,
.group:after { content:""; display:table; }
.group:after { clear:both;}
.group { zoom:1; /* For IE 6/7 */ }
/* GRID OF TWO */
.span_2_of_2 {
width: 100%;
}
.span_1_of_2 {
width: 49.2%;
}
/* GO FULL WIDTH AT LESS THAN 480 PIXELS */
@media only screen and (max-width: 480px) {
.col {
margin: 1% 0 1% 0%;
}
}
@media only screen and (max-width: 480px) {
.span_2_of_2, .span_1_of_2 { width: 100%; }
}
&#13;
<div class="section group">
<div class="col span_1_of_2">
This is column 1
</div>
<div class="col span_1_of_2">
This is column 2
</div>
</div>
&#13;