Rails邮件发送器样式设计

3
为什么我在邮箱中收到了默认样式的邮件?我在代码中对其进行了一些样式设置,但为什么在Gmail上看到的却是默认布局呢? 我的代码如下:
!!!
%html
  %head
    %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
      %title Покупка автозапчастей
      :css
        body, td { background-color:#cecece; color:#000000; font-size:14px; font-family:Verdana,Helvetica,Arial; }
        .blue { background-color: blue; height:2px; color: white; }
        .notice {margin: 10px auto;  background-color: #fbb752;  border: 1px solid #cecece; }
  %body
    .blue
      %h3
        Новый заказ
      %b
        Внимание, недавно на сайте сформирован новый заказ!
        = @order.id
    .notice
      %table
        %tr
          %th
            id клиента
          %th
            Улица
          %th
            Здание
          %th
            Общая сумма
          %th
            Статус
          %th
            Открыт
        %tr
          %td
            = @order.user.id
            = @order.user.email
          %td
            %b
              = @order.street
          %td
            = @order.building
          %td
            %b
              = @order.totalcost
          %td
            %b
              = @order.orderstatus.name
          %td
            = @order.created_at
      %br/
      %table
        %tr
          %th
            Артикул
          %th
            Цена
          %th
            Количество      
        - @order.line_items.each do |l|
          %tr{ :class => cycle("zebra-stripe zebra-grey zebra1", "zebra-stripe zebra-grey zebra2")}      
            %td
              = l.description
            %td
              = l.price
            %td
              = l.quantity

那么,我如何做到让我的邮件发送到我的电子邮件服务(Gmail)中,以与我的代码中一样好的样式呢?
1个回答

9

Gmail会删除HTML邮件中的所有<style>标签。

如果要在Gmail中显示样式,需要使用内联样式属性。


请注意,有一些工具可以将CSS自动转换为内联样式。使用谷歌搜索即可找到。 - mreq
还有其他服务上我也没有看到我的布局!问题在代码中。 - brabertaser19
@brabertaser1992:那是因为他们确实使用了 style="" 属性。 - SLaks
嘿,你去哪里了? - brabertaser19
1
@brabertaser1992:不要使用CSS选择器来应用属性,而是需要直接将它们应用于每个元素,使用style = ""属性。 - SLaks
显示剩余4条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接