css Outlook忽略字体大小

t8e9dugd  于 2023-06-07  发布在  其他
关注(0)|答案(1)|浏览(136)

使用:

<html>
<head>
<style>
  p {
    font-size: 16px;
  }
  .font-size-16 {
    font-size: 16px !important;
  }
</style>
</head>
<body>
  <p>Duis eros mauris, sodales et ullamcorper ac, ultrices vitae mi. Morbi scelerisque tristique nibh, eget venenatis erat mattis maximus. Donec vestibulum auctor consectetur.</p>
  <!--[if mso]>
    <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://example.com/contact/support/" style="font-family: Verdana, Geneva, sans-serif; height: 54px !important; width: 125px !important; padding-top: 10px; text-decoration: none; background-color: #2747d7!important; color: #fff !important; v-text-anchor:middle;" arcsize="20%" strokecolor="white" fillcolor="#2747d7">
        <w:anchorlock/>
        <center class="font-size-16" style="color:#ffffff; font-size:16px;">Contact us</center>
    </v:roundrect>
  <![endif]-->
</body>
</html>

段落字体大小始终显示为16px,但<v:roundrect><center>显示在各种不同的字体大小,通常约2px小,在不同版本的Outlook。
我们如何在Outlook中实现一致的字体大小,并在上面的示例中作为<v:roundrect><center>的样式?
this answer,我已经从内联样式中删除了!important;,并向<head>添加了一个样式,但问题仍然存在。
感谢帮助。

解决方案

内森的回答提示了解决方案:

<style>
    body {
        font-family: Verdana, Geneva, sans-serif;
        font-size: 16px;
    }
</style>
<!--[if mso]>
<style>
    .font-size-override-button {
        font-size: 12pt !important;
        text-decoration: none;
    }
</style>
<![endif]-->

<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://www.example.com/contact/support/" style="height:39px;v-text-anchor:middle;width:125px;" arcsize="30%" stroke="f" fillcolor="#2747d7">
    <w:anchorlock/>
    <center>
    <![endif]-->
        <a href="https://www.example.com/contact/support/" class="font-size-override-button" style="background-image: linear-gradient(90deg, #2747D7 0%, #6127E7 51%, #2747D7 100%) !important; background-position-x: 0 !important; background-position-y: 0 !important; background-repeat: no-repeat !important; background-size: 200% auto !important; background-color: #2747d7 !important; border-radius:8px;color:#ffffff;display:inline-block;font-family:Verdana,Geneva,sans-serif;font-weight:bold;line-height:39px;text-align:center;text-decoration:none;width:125px;-webkit-text-size-adjust:none;">Contact us</a>
    <!--[if mso]>
    </center>
</v:roundrect>
<![endif]-->
m1m5dgzv

m1m5dgzv1#

用pt代替px。当有不同版本的Outlook显示不同的东西,这通常是它。3pt = 4px,所以12pt = 16px。
<center style="color:#ffffff; font-size:12pt;">Contact us</center>
我想你也需要这个在头上,如果它不是已经:

<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"  xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<!--[if mso]><xml>
  <o:OfficeDocumentSettings>
    <o:AllowPNG/>
    <o:PixelsPerInch>96</o:PixelsPerInch>
  </o:OfficeDocumentSettings>
</xml><![endif]-->

相关问题