如何制作适用于移动设备和桌面的电子邮件模板?

时间:2014-11-02 17:06:46

标签: html css ruby-on-rails email responsive-design

就我而言,我使用Roadie gem为自动电子邮件自定义CSS和HTML。然而,问题是普通台式机/笔记本电脑电子邮件客户端的样式看起来很棒,但在移动电子邮件客户端看起来很糟糕

似乎没有任何响应方式来处理移动电子邮件设计。关于如何在移动和台式机/笔记本电脑设备上使电子邮件看起来相同的任何想法?

这是电子邮件模板代码:

<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title><%= Saas::Config.app_name %></title>
<link href="http://fonts.googleapis.com/css?family=Oswald:400,300,700" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700' rel='stylesheet' type='text/css'>
<style type="text/css">
  body{font-family: 'Source Sans Pro', sans-serif;background: #eeeeee;}
  .container{width: 570px;margin: auto;padding: 40px 0;}
  .main {padding: 70px 100px;font-weight: 300;background: #fff;}
  .header{background: #cc0000;padding: 10px 0 5px 25px;min-height: 40px;}
  .logo{float: left;}
  .credo{color: white;font-style: italic;font-size: 16px;margin-left: 230px;margin-top: 10px;}
  .footer {background: #7e7e7e;text-align: center;color: #fff;font-weight: 100;padding: 15px 0;}
  .h8{font-size: 28px; font-weight: 300;}
  .red, .red a{color: #d93f3f;text-decoration: none;}
  div.text{font-size: 20px;color:#616161;margin-bottom: 5px;}
  .justify{text-align: justify;}
  .blue, .blue a{color: #3fb2ff;}
  .get_started{background: #66ccff;color: #fff;text-decoration: none;padding: 10px 30px;font-weight: 400;font-size: 22px;}
</style>
</head>
<body>
  <div class="container">
    <div class="header">
      <%= image_tag 'logo.png', class: 'logo' %>
      <div class="credo">Credo here</div>
    </div>
    <div class="main"><%= yield %></div>
    <div class="footer">
      <span>&copy;2014 AppName Inc, 27001 Address</span>
    </div>
  </div>
</body>
</html>

基本上,我希望在两种媒体(浏览器和移动设备)上尽可能接近显示电子邮件。

1 个答案:

答案 0 :(得分:1)

这样的事情应该有效http://jsfiddle.net/3y49x8vs/

基本上你应该改变.container width:570px;到这个

.container {
    width: 100%;
    max-width: 570px;
    margin: auto;
    padding: 40px 0;
}