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/

相关文章:

java - 根据 TLD 获取标签 [form] 的属性 [modelAttribute] 无效

javascript - 如何将当前日期的两天添加到隐藏输入的值

html - 由于 li 填充,Chrome 和 Opera 在顶部留下了空白空间

javascript - 从 Javascript 设置一个 PHP 变量并从 &lt;style&gt; 读入

html - 无法在 UL + LI (CSS) 中隐藏 HTML

html - 我们可以增加html中的字体大小吗?

javascript 中的 php

javascript - wrap() 多次重复元素 - jQuery

javascript - CSS - 移动菜单触发器

html - 根据屏幕大小调整字体大小