为什么只有部分单元格顶部对齐? [英] Why is only part of cell top aligned?

查看:89
本文介绍了为什么只有部分单元格顶部对齐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有标记看起来像这样:

I have markup looking something like this:

<html>
    <head>
        <style>
            table.t_group {
                border: 2px solid black;
                margin: 0 auto 0 auto;
            }
			
            table.t_group > tbody > tr > td {
                vertical-align: top;
            }
        </style>
    </head>	
    <body>
        <table class="t_group" style="width:500px">
            <tbody>
                <tr>
                    <td>
                        <img height="24" widht="24"/> First cell
                    </td>
                    <td>
                        Last cell
                    </td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

是单元格中的文本与图像的垂直对齐。不管什么原因,它都是底部对齐的,但我希望它与顶部对齐。

The key problem is vertical alignment of text in cells with an image. For whatever reason, it is aligned to bottom, but I expect it to be aligned to top.

为什么会发生这种情况?如何将单元格中的文本与图像对齐到顶部?

Why does it happen this way? How to align text in cells with images to top?

推荐答案

使用

使用:

table img{
  vertical-align:top;
}

jsBin操场

https://developer.mozilla.org/en/docs/Web/CSS/vertical-align a>

这篇关于为什么只有部分单元格顶部对齐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆