本文介绍了如何在div内部垂直对齐div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将div的顶部与div对齐,但没有成功. http://jsfiddle.net/jhbs31xv/

I am trying to top align a div inside of a div and I'm having no success. http://jsfiddle.net/jhbs31xv/

<table style="border: 1px solid red; width: 100%">
    <tr>
        <td>
            <div style="display: table-cell; width: 200px; height: 500px; overflow-y: auto;">
                <div id="housingTree" class="demo" style="height: 100px;">
                </div>
            </div>
        </td>
        <td style="width: 100%; height: 100%; border: 1px solid blue;">
            <div style="height: 100%; width: 100%;">

                <div id="infoPane" style="width:100%;margin-left:10px; border: 1px solid green;vertical-align:top; ">
                    How To Top Align Me?

                </div>

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

推荐答案

像这样:

<td style="width: 100%; height: 100%; border: 1px solid blue;" valign="top">
        <div style="height: 100%; width: 100%;">

            <div id="infoPane" style="width:100%;margin-left:10px; border: 1px solid green; ">
                How To Top Align Me?

            </div>

        </div>
    </td>

将valign ="top"添加到包含的内容.

Add valign="top" to the containing .

而且,正如Goos van den Bekerom提到的那样,您不应该在td中添加div....

And, as Goos van den Bekerom mentions, you shouldn't have a div in a td....

这篇关于如何在div内部垂直对齐div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 15:54