html - 为什么 outlook 会拉长我的图像高度?

标签 html css email outlook html-email

这周我了解到 html 电子邮件这一奇迹。我有一封电子邮件需要并排显示图像和一些文本。我遇到的问题是图像被垂直拉伸(stretch),而不是高度由宽度自动设置。 这个问题只发生在outlook中。

这是正在呈现的内容: enter image description here

这是组成它的代码:

<table class="container" align="center" width="640" cellpadding="0" cellspacing="0">
  <tr>
    <td width="256" style="width:40%; float:left; text-align:right;">
      <img class="max-image" width="256" style="display:block;width:100%; height:auto;" src="https://cdn.pixabay.com/photo/2015/06/25/17/56/people-821624_1280.jpg" alt="coach picture"/>
    </td>
    <td width="384" style="width:60%; float:left; text-align:center;">
      <table width="100%">
        <tr>
          <td width="10"></td>
          <td>
            <div style="padding-left: 10px;text-align: center;">
              <p style="color:#6AA342;"><strong>Meet The Coach</strong></p>
              <p>{{ coach_first_name }}</p>
              <p>{{ bio }}</p>
            </div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

到目前为止,从我在网上收集到的信息来看,当您没有明确设置图像的高度属性时,outlook 似乎并不喜欢,但我遇到的问题是该图像是动态设置的,它可能是每个电子邮件的纵横比不同,所以我无法真正设置图像的高度。

最佳答案

如果您查看以下行:

<td width="256" style="width:40%; float:left; text-align:right;">

您可能会看到 Outlook 不支持的 float:left 属性。事实上,Outlook 使用 Word 呈现 HTML 正文。

您可以在以下文章中找到支持和不支持的 HTML 元素、属性和级联样式表属性的完整列表:

关于html - 为什么 outlook 会拉长我的图像高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57378213/

相关文章:

html - #{} 不适用于 ruby​​ on rails

来自 MYSQL 的 Python 电子邮件表

php swiftmailer 发送带有 smtp 传输超时的邮件

javascript - 通过 css 和 jquery 将第一个和最后一个 child 应用于某个 <tr> id

javascript - 使用 scapy 将通过网络发送的凭据存储到文件/数据库并按客户端的 IP 对条目进行分类

html - 在css中的元素后插入上下文

html - 如何防止光标输入垃圾邮件悬停元素?

javascript - 用js改变css类

jquery - 设置验证字段失败的标志

PHP电子邮件表单多选