我的 PHP HTML 电子邮件表单的某些 CSS 未进入邮件表单

我正在使用 PHPMailer 发送电子邮件,但发送时表单 CSS 的各个方面不会进入邮件:

  1. 调整内容:居中;

  2. 对齐项目:居中

  3. 还有字体系列。

  4. 轮廓偏移:5px;

有谁能告诉我为什么这些 CSS 没有进入发送的电子邮件表单,而所有其他 CSS 加载都没有问题?

如果我在控制台中输入这些值,它们就会起作用,所以我不明白为什么在发送邮件时这些 CSS 值会从 DOM 中删除。

这是我的代码:

<style>@import url("https://fonts.googleapis.com/css2?family=Thasadith:ital,wght@0,400;0,700;1,400;1,700&display=swap");</style>

        <div style="background-color: #ffffff; margin: auto; width: 65%; border: 1px solid #e1e1e1; outline: 1px solid #e1e1e1; outline-offset: 5px; margin-top: 25px; margin-bottom: 25px;padding: 5px;">

                <div style="display: flex; justify-content: center; align-items: center; background-color: #f35653; margin-bottom: 20px; padding: 30px 0px;">

                <div style="background-image: url(https://i.imgur.com/XPTHrId.png); background-position: center; background-size: cover; width: 50px; height: 50px;"></div>

                <div style="font-size: 40px; text-transform: uppercase; align-self: center; color: white; font-family: Thasadith, sans-serif; font-weight: 700; margin-left: 5px;">Enkou Academy</div></div>

                <div style="padding: 10px 40px 40px;font-size: 15px;">

                <p>We received a request to reset the password for your Enkou Academy account.<br><br>

                To reset the password, click on the link below:<br><br>

                <a href="' . $url . '" style="text-decoration: none; color: #f35652;">Click here!</a><br><br>

                If you didn&#39;t request a password reset, let us know.</p>

                </div>

        </div>'


长风秋雁
浏览 76回答 0
0回答

哆啦的时光机

例如这样写:<style type="text/css">@font-face {  font-family: 'Thasadith';  font-style: italic;  font-weight: 400;  font-display: swap;  src: local('Thasadith Italic'), local('Thasadith-Italic'), url(https://fonts.gstatic.com/s/thasadith/v3/mtG-4_1TIqPYrd_f5R1osnMX-CE.woff2) format('woff2');  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;mso-font-alt: Arial;}</style>请注意添加了 Outlook 字体后备 ( mso-font-alt)。
打开App,查看更多内容
随时随地看视频慕课网APP