【问题标题】:Gmail application displays font size and color wrongGmail 应用程序显示字体大小和颜色错误
【发布时间】:2014-08-08 17:02:12
【问题描述】:

我有带有表格的 php/html 代码。它在 yahoo、gmail 等中看起来非常好,但是当仅在手机上的 gmail 应用程序中打开时,看起来很乱,奇怪的绿色和错误的不同字体大小。知道如何解决这个问题吗?下面的链接包含 2 个屏幕截图。左边是它在包括 gmail 在内的所有电子邮件帐户上的外观。右边是它在 iPhone 上的 gmail 应用程序上的外观。

Link for the screenshot

代码如下:

<?php 
// Fixes the encoding to uf8 
function fixEncoding($in_str) 
{ 
  $cur_encoding = mb_detect_encoding($in_str) ; 
if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8")) 
return $in_str; 
else 
return utf8_encode($in_str); 
} // fixEncoding 
?>
<?php


require_once('class.phpmailer.php');

//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not     already loaded

$mail             = new PHPMailer();

$body = '<html><body>';
$body .= '<table rules="all" style="border-color: #fff; font-family: Arial; width:595px;     height:108px; font-size:115%; background-color:#ffffff;" cellpadding="10">';
$body .= "<tr><td style='text-align: center; text-align: middle; vertical-align: middle;      vertical-align: center'>
 <img style='border: 0px solid ;     'src='http://www.magentastorage.co.uk/mobile/images/emailheader.jpg'></a> </td></tr>";

 $body .= '</table>';

 $body .= '<table rules="all" style="border-color: #fff; font-family: Arial; width:595px; font-size:115%; background-color:#ffffff;" cellpadding="10"; position:relative; left:"20">';

$body .= "<tr><td style= 'padding-left:21px;'>Dear  " .$_GET["name"] ."," . "</td></tr>";
$body .= "<tr><td style= 'padding-left:21px;'>Thank you for visiting our website and contacting us about your storage requirements. Below is a summary of your storage quotation:  </td></tr>";
$body .= "<tr> <td style='text-align: left; font-family: Arial; vertical-align: left;'>
 <img style='border: 0px solid ; ' src='http://www.magentastorage.co.uk/mobile/images/emailrequirements.png'> </td></tr>";

$body .= '</table>';

$body .= '<table rules="all" style="border-color: #fff; font-family: Arial; width:470px; font-size:115%; background-color:#ffffff;" cellpadding="10">';

    $body .= "<tr>";
$body .= "<td style= 'padding-left:21px;'>Unit Size:</td>";
$body .= "<td>";
$body .= $_GET["unitsize"];
$body .= "</td>";
$body .= "<td></td>";
$body .= "</tr>";


    $body .= '</table>';

$body .= '<table rules="all" style="border-color: #fff; font-family: Arial; width:595px; font-size:115%; background-color:#ffffff;" cellpadding="10">';

$body .= "<tr> <td style='text-align: left; font-family: Arial; vertical-align: left;'>
 <img style='border: 0px solid ; '
 src='http://www.magentastorage.co.uk/mobile/images/emailquotation.png'> </td></tr>";
$body .= "<tr><td style= 'padding-left:21px;'>" ."Weekly rental is" ." " ."&pound;" .$_GET["price"] ." "     ."</td> </tr>";
$body .= "<tr><td style= 'padding-left:21px;'>This quote includes VAT, insurance cover for up to" ." " ."£" .$_GET["insurance"] ." " ."and a padlock to secure your storage unit</td></tr>";
$body .= "<tr><td style= 'padding-left:21px;'>" ."<strong>" ."**4 WEEKS FREE STORAGE**" ."</strong>" ."</td>";
$body .= "<tr><td style= 'padding-left:21px;'>Simply pay for 4 weeks storage when you move in and we'll give you an extra 4 weeks storage completely free!</td></tr>";

$body .= "<tr><td style= 'padding-left:21px;'>Kind Regards, </td></tr>";
$body .= "<tr><td style= 'padding-left:21px;'>Store Manager </td></tr>";

$body .= "</table>";
$body .= "</body></html>";

【问题讨论】:

  • 尝试将 min-width:595px 添加到您的全角 td 之一。 Gmail 不遵循常规宽度样式,似乎只遵循单元格上的 min-width。
  • 感谢@Narong 的评论。不幸的是,它没有解决它。

标签: php css html-table gmail html-email


【解决方案1】:

我对 PHP 的了解不够,无法为您提供任何提示,但我发现静态 HTML 位有很多问题。

<td style='text-align: center; text-align: middle; vertical-align: middle;      vertical-align: center'>

在这里,您设置了两次垂直对齐。 vertical-align: center 无效,应删除。我还会在此样式声明中添加min-width:595px

<table rules="all" style="border-color: #fff; font-family: Arial; width:595px; font-size:115%; background-color:#ffffff;" cellpadding="10"; position:relative; left:"20">

而不是border-color: #fff,只需创建整个边框。 border: 3px solid #ffffff。您在样式声明之外有 position:relative; left:"20",因此应该移动它们。此外,您需要为您的 left 值添加一个单位并删除 cellpadding="10"; 中的分号。

<td style='text-align: left; font-family: Arial; vertical-align: left;'>

您不能设置垂直左对齐。

此外,在处理电子邮件时,最好使用完整的 6 个字符的十六进制代码。 border: 0px solid 可以替换为 border: 0。我还建议使用绝对字体大小,而不是相对百分比。

再说一次,我不知道你的 PHP 有多可靠,但看到你的 HTML/CSS 中有很多错误,我建议你把它整理一下,你的电子邮件可能会表现得更好一些。

【讨论】:

  • 谢谢@Narong,但还是没有运气。
  • 嗯.. 你能从 Gmail 中获取和分享源 HTML 吗?我不确定如何在 Gmail 应用程序中执行此操作,但如果要发送到 Gmail 地址,您可以通过单击回复箭头旁边的三角形从网站上获取代码 -> 显示原件
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-09
  • 2019-04-07
  • 1970-01-01
  • 2014-11-03
  • 1970-01-01
相关资源
最近更新 更多