CSS无法在Devise(Rails)Mailer for Gmail

时间:2016-06-16 20:22:07

标签: html css ruby-on-rails devise actionmailer

我在用户注册后发送确认电子邮件。我使用设计的邮件程序视图。 似乎其他一切都正常,但CONFIRM ACCOUNT的CSS根本没有被调用。我读到我不能将CSS类用于邮件程序视图,因此我将所有内容设置为内联样式。当我在我的网络应用程序上查看邮件程序视图时,它看起来很像下面的

enter image description here

但在实际的邮件程序视图中,它看起来像这样:

enter image description here

以下是我的代码:

<body style="background-color: #F7F7F7;">
<div class="main wrapper clearfix">
    <div style="border: 1px solid #e4e4e4;
        border-radius: 5px;
        margin: 50px auto;
        padding: 20px 50px;
        box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.15);
        background-color: white;
        max-width: 700px;">
        <div style="text-align:center">
            <%= image_tag("logo-green.svg") %>
        </div><br><br>
        <div>
            <p>Welcome <%= @user.first_name %>!</p>

            <p style="line-height: 1.5">Let's confirm your email address. Click the button below to confirm your email.</p>

            <%= link_to 'CONFIRM ACCOUNT',
            confirmation_url(@resource, confirmation_token: @token),
            style: "font-family: Raleway-SemiBold, sans-serif;
                -webkit-font-smoothing: antialiased;
                display: inline-block;
                cursor: pointer;
                text-decoration: none;
                color: white;
                letter-spacing: 1px;
                    padding: 13px 30px;
                    font-size: 0.8em;
                    color: #fff;
                    background-color: #00BA9B;
                    transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
                    transition-delay: 0.2s;
                    box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.26);
                    margin-top: 25px;
                    margin-bottom: 20px;
                    border-radius:" %>

            <br><br>
            <p style="line-height: 1.5">Thanks,<br>website <br> <a href="www.website.com" style="color: #00BA9B; text-decoration:none">www.website.com</a></p>
            <br>

             <p style="color:grey; font-size:11px;">P.S. If you didn't sign up for website, please ignore this email - apologies for the disturbance.<p>
        </div>
    </div>
</div>
</body>

<a href="www.website.com" style="color: #00BA9B; text-decoration:none">www.website.com</a>上的样式在邮件程序视图中正常工作。但是在CONFIRM ACCOUNT上的线条样式不起作用。 我很想知道为什么内联样式在其他地方工作但不在link_to 'CONFIRM ACCOUNT',上。

1 个答案:

答案 0 :(得分:2)

电子邮件客户端HTML存在很多限制。 This guide shows you what you can and cannot do with email HTML.

所有这些过渡,自定义光标,阴影?那不会飞。

相关问题