将一个桌子居中并对齐一个div

时间:2013-08-20 20:12:22

标签: html css

我没有太多运气使pageLinks表居中并且在pagingDiv div中右对齐goToPage div。我需要这两个元素位于同一垂直水平。任何帮助将不胜感激。

<div id="pagingDiv" style="border:1px solid black; width:100%;">
    <table id="pageLinks" style="border:1px solid black; margin:auto;" >
        <tbody>
            <tr>
                <td>
                    <a href="#first" title="Click to go to first page.">1</a>
                </td>
                <td>
                    <a href="#first" title="Click to go to second page.">2</a>
                </td>
            </tr>
        </tbody>
    </table>                  
    <div id="goToPage" style="float:right"> &nbsp; Page 3 of 42 | Page#: <input style="height:14px;width:21px;" /> <a href="#go">GO</a></div>                  
</div>

1 个答案:

答案 0 :(得分:1)

在HTML中的表格之前移动goToPage div:

<div id="pagingDiv" style="border:1px solid black; width:100%;">
    <div id="goToPage" style="float:right">&nbsp; Page 3 of 42 | Page#:
        <input style="height:14px;width:21px;" /> <a href="#go">GO</a>
    </div>
    <table id="pageLinks" style="border:1px solid black; margin:auto;">
        <tbody>
            <tr>
                <td> <a href="#first" title="Click to go to first page.">1</a>

                </td>
                <td> <a href="#first" title="Click to go to second page.">2</a>

                </td>
            </tr>
        </tbody>
    </table>
</div>

<强> jsFiddle example