作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望 #idTable
和 #userTable
并排放置,按钮位于 #idTable
下方。我试过 display: inline-block;
但没有用。此外,我曾尝试将按钮放在 div#userTable
之后,但这会使每次该表填充更多数据时按钮下降更多。我希望按钮保持在左侧。 #userTable
及其信息位于第一个表的右侧。
HTML:
<input type="date" />
<input type="date" />
<br style="clear:both" />
<table border="1" id="idTable">
<tr>
<th><b>#</b>
</th>
<th><b>ID</b>
</th>
</tr>
<tr>
<td>// #'s here</td>
<td>// ID's here</td>
</tr>
</table>
<br style="clear:both" />
<button>Update</button>
<div id="userTable">
<table border="1">
<tr>
<td><b>ID</b>
</td>
<td>Name</td>
</tr>
<tr>
<td colspan="2">
<table border="1" style="width:100%">
<tr>
<td><b>ID</b></td>
<td><b>Name</b></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
CSS:
#idTable{
display:inline-block;
}
#userTable{
display:inline-block;
}
最佳答案
您可以将 #idTable
和按钮放入另一个 div
(例如 #wrapper
)并设置其 float
property到左边
。
HTML:
<div id='wrapper'>
<table border="1" id="idTable">
<tr>
<th><b>#</b>
</th>
<th><b>ID</b>
</th>
</tr>
<tr>
<td>// #'s here</td>
<td>// ID's here</td>
</tr>
</table>
<button>Update</button>
</div>
CSS:
#wrapper {
float: left;
}
关于html - 两张 table 紧挨着,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32185008/
我是一名优秀的程序员,十分优秀!