垂直对齐不按预期的HTML工作

发布于 2025-01-25 10:57:31 字数 2333 浏览 5 评论 0原文

我正在创建HTML电子邮件签名,由于某种原因,我在垂直垂直对齐图像和一些文本时遇到了问题。我正在通过打开Chrome/Gmail的HTML来查看我的签名,该HTML的作用相同,然后在Outlook中单独检查以检查兼容性问题。垂直对齐都无法使用,但输出的输出略有不同。

我希望解决方案,以垂直对齐图像并在中间垂直将镀铬/gmail和Outlook在中间放置。

我尝试了许多不同的垂直对齐方法,例如在各种元素上使用行高,垂直对齐,高度和显示属性,但它们没有任何区别。

以下是我的代码:

<table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" style="margin: 20px 0;width: 600px; border-collapse: collapse;">
    <tr>
        <td cellspacing="0" cellpadding="0" border="0" width="180" height="22" style="font-family: Urbanist, Arial, sans-serif; text-align: left; font-size:16px; font-weight: 400; color: #000; padding: 0 0 0 20px;">
            <p style="margin: 0;"><img src="/assets/signature/phone.png" width="22" height="22" style="margin: 0 5px 0 0; width: 22px; height: 22px;" /> XXXXX XXXXXX</p>
        </td>
        <td cellspacing="0" cellpadding="0" border="0" width="240" height="22" style="font-family: Urbanist, Arial, sans-serif; text-align: center; font-size:16px; font-weight: 400; color: #000;">
            <p style="margin: 0;"><span style="text-decoration: none!important; color: #000!important;"><img src="/assets/signature/email.png" width="22" height="22" style="margin: 0 5px 0 0; width: 22px; height: 22px;" /> [email protected]</span></p>
        </td>
        <td cellspacing="0" cellpadding="0" border="0" width="180" height="22" style="font-family: Urbanist, Arial, sans-serif; text-align: right; font-size:16px; font-weight: 400; color: #000; padding: 0 20px 0 0;">
            <p style="margin: 0;"><img src="/assets/signature/web.png" width="22" height="22" style="margin: 0 5px 0 0; width: 22px; height: 22px;" /> www.domain.com</p>
        </td>
    </tr>
</table>

这是我在Chrome/gmail中的输出:

这是我在Outlook中的输出:

I'm creating an HTML email signature and for some reason I'm having an issue with aligning an image and some text in the middle vertically. I am looking at my signature by opening the HTML in Chrome/Gmail which both act the same and then separately in Outlook to check for compatibility issues. The vertical alignment doesn't work in either but do output slightly differently.

I'd like a solution to vertical align the image and text together in the middle vertically for both Chrome/Gmail and Outlook.

I've tried lots of different vertical align methods such as using line-height, vertical-align, height and display properties on various elements but they don't make any difference.

Below is my code:

<table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" style="margin: 20px 0;width: 600px; border-collapse: collapse;">
    <tr>
        <td cellspacing="0" cellpadding="0" border="0" width="180" height="22" style="font-family: Urbanist, Arial, sans-serif; text-align: left; font-size:16px; font-weight: 400; color: #000; padding: 0 0 0 20px;">
            <p style="margin: 0;"><img src="/assets/signature/phone.png" width="22" height="22" style="margin: 0 5px 0 0; width: 22px; height: 22px;" /> XXXXX XXXXXX</p>
        </td>
        <td cellspacing="0" cellpadding="0" border="0" width="240" height="22" style="font-family: Urbanist, Arial, sans-serif; text-align: center; font-size:16px; font-weight: 400; color: #000;">
            <p style="margin: 0;"><span style="text-decoration: none!important; color: #000!important;"><img src="/assets/signature/email.png" width="22" height="22" style="margin: 0 5px 0 0; width: 22px; height: 22px;" /> [email protected]</span></p>
        </td>
        <td cellspacing="0" cellpadding="0" border="0" width="180" height="22" style="font-family: Urbanist, Arial, sans-serif; text-align: right; font-size:16px; font-weight: 400; color: #000; padding: 0 20px 0 0;">
            <p style="margin: 0;"><img src="/assets/signature/web.png" width="22" height="22" style="margin: 0 5px 0 0; width: 22px; height: 22px;" /> www.domain.com</p>
        </td>
    </tr>
</table>

This is my output in Chrome/Gmail:
1

This is my output in Outlook:
2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪化雨蝶 2025-02-01 10:57:31

那:

table tr {
  display: flex;
  align-items: center;
}

What about:

table tr {
  display: flex;
  align-items: center;
}

?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文