html - 如何让这些表堆叠在一起?

标签 html css

如何让这些表格在没有额外空间的情况下相互滑动?

enter image description here

<table border="0">
    <tbody>
        <tr>
            <th>And another</th>
        </tr>
        <tr>
            <td>Some stuff in the table. </td>
        </tr>
        <tr>
            <td>Some stuff in the table. </td>
        </tr>
        <tr>
            <td>Some stuff in the table. </td>
        </tr>
    </tbody>
</table>

<table border="0">
    <tbody>
        <tr>
            <th>And another</th>
        </tr>
        <tr>
            <td>Some stuff in the table. </td>
        </tr>
        <tr>
            <td>Some stuff in the table. </td>
        </tr>
    </tbody>
</table>

<table border="0">
    <tbody>
        <tr>
            <th>And another</th>
        </tr>
        <tr>
            <td>Some stuff in the table. </td>
        </tr>
        <tr>
            <td>Some stuff in the table. </td>
        </tr>
        <tr>
            <td>Some stuff in the table. </td>
        </tr>
    </tbody>
</table>

<table border="0">
    <tbody>
        <tr>
            <th>And another</th>
        </tr>
        <tr>
            <td>Some stuff in the table. </td>
        </tr>
        <tr>
            <td>Some stuff in the table. </td>
        </tr>
        <tr>
            <td>Some stuff in the table. </td>
        </tr>
    </tbody>
</table>

CSS

/* ---------------[ Tables ]--------------- */

table {
    float: left;
    width: 285px;
    }

tr, td, th {
    margin:auto; 
    }

td, th {
    padding:5px;
    vertical-align:top;
    }

th {
    font-weight:bold;
    background:#ddd;
    }

td {
    border:1px solid #ddd;
    }

谢谢

最佳答案

您可以尝试将 clear: left 添加到您的表中:

table {
    float: left;
    clear: left;
    width: 285px;
}

演示:http://jsfiddle.net/ambiguous/AsUSj/

您可能需要在 fiddle 中使用面板尺寸来说服自己它有效。

关于html - 如何让这些表堆叠在一起?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7774826/

相关文章:

jquery - 如何在上面有文字的图像上添加浅黑色叠加层?

html - 缩进所有 child

javascript - 在 Javascript 中出现未定义的字符串约束错误

javascript - 使用 javascript 检索 html 数据

html - 在 CSS/HTML 中扩展我的导航栏的边(就像标题一样)

html - 使用 anchor 链接的导航不起作用

javascript - 当按下 HTML 按钮时如何显示从 PHP 函数返回的数据

jquery - 搜索栏不显示 rel 标签

css - 使用 line-clamp 和嵌套的 p 标签夹紧线

css - 如何在 Bootstrap 中正确使用 padding 和 margins