如何将一个表格放在另一个表格下面

4
如果我已经使用了align,那么如何将一个表格放在另一个表格下面?
           center_table
left_table
           desired_table

但是我得到了以下结果。
           center_table
left_table desired_table

这是我的HTML代码。
居中的表格
    <table align="left">
        <tr>
            <td>left_table</td>
        </tr>
    </table>

    <table align="center">
        <tr>
            <td>desired_table</td>
        </tr>
    </table>

不使用CSS仅使用HTML

3个回答

4

在你的两个表格之间添加一个<div style = "clear:both;"></div>。然后它应该就可以正常工作了。

clear属性指定元素不允许浮动元素的哪一侧。

你可以在这里找到更多详细信息:http://www.w3schools.com/cssref/pr_class_clear.asp

<table align="left">
  <table align="left">
    <tr>
        <td>left_table</td>
    </tr>
  </table>
  <div style="clear:both;"></div>

  <table align="center">
    <tr>
        <td>desired_table</td>
    </tr>
  </table>
</table>

或者

 <table align="left">
    <tr>
        <td>left_table</td>
    </tr>
  </table>

  <div style="clear:both;"></div>

  <table align="center">
    <tr>
        <td>desired_table</td>
    </tr>
  </table>

1
对于左对齐表格,请将宽度更改为100%,即可正常使用。
<table align="center" >
    <tr>
        <td>left_table</td>
    </tr>
</table>
<table align="left" width="100%">
    <tr>
        <td>left_table</td>
    </tr>
</table>
<table align="center" >
    <tr>
        <td>desired_table</td>
    </tr>
</table>

0

结果 -> http://jsfiddle.net/0LtqL8yh/embedded/result/

 <table border=1 width=80% height=30% align=left cellpadding=1 cellspacing=1>
        <tr height=30%>
            <td>First Row</td>
            <td>First Row</td>
            <td>First Row</td>
        </tr>
        <tr height=70%>
            <td>Second Row</td>
            <td>
                <table bgcolor=yellow border=1 width=80% height=80% align="center">
                    <tr>
                        <td>Inner Table</td>
                        <td>Inner Table</td>
                    </tr>
                    <tr>
                        <td>Inner Table</td>
                        <td>Inner Table</td>
                    </tr>
                </table>
            </td>
            <td>Second Row</td>
        </tr>
    </table>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接