【问题标题】:Using CSS & HTML with MFMailComposeViewController将 CSS 和 HTML 与 MFMailComposeViewController 一起使用
【发布时间】:2010-11-21 03:27:21
【问题描述】:

当我将它与 MFMailComposeViewController 一起使用时,我的 CSS 格式会丢失。下面是我的示例代码。我只是在正文部分下插入我的表格数据。

<html>
<head>
  <style type="text/css">
    #customers {
      font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
      width: 100%;
      border-collapse: collapse;
    }
    #customers td,
    #customers th {
      font-size: 1em;
      text-align: right;
      border: 1px solid #999999;
      padding: 10px 25px 5px 25px;
    }
    #customers th {
      font-size: 1.1em;
      text-align: center;
      padding: 10px 25px 5px 25px;
      background-color: #ffffff;
      color: #000000;
    }
  </style>

</head>

<body>

  %@

</body>

</html>

我在撰写电子邮件时设置了“isHTML=YES”。我是否遗漏了什么,或者在使用 MFMailComposeViewController 的 iphone 上不支持这种使用 CSS 的方法

【问题讨论】:

  • 如果您合理地格式化您的帖子会有所帮助。

标签: iphone html css mfmailcomposeviewcontroller


【解决方案1】:

我不清楚,但您是将 CSS 放在 &lt;body&gt;&lt;head&gt; 中吗?我相信MFMailComposeViewController 需要在&lt;body&gt;&lt;/body&gt; 标签内定义CSS。

【讨论】:

  • 除了&lt;style&gt; 内的&lt;body&gt; 不是有效的HTML,IIRC。即使它确实通过了,它也可能无法在所有邮件客户端中正确呈现(并且它晚上会被 webmail 剥离 - 否则它可能是一个安全风险)。我只好硬着头皮使用style 属性。
  • 啊……你让我很开心。是的,CSS 在错误的部分。非常感谢:-)
  • hmmm ...当我在 iphone 上查看电子邮件时格式存在,但当我在浏览器中的 gmail 中查看它时它丢失了?任何想法
  • 不确定,你按照@tc 说的做了吗?并使用内联style=''?
  • Gmail 会自动删除很多样式项目。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-04
  • 2011-03-09
  • 1970-01-01
  • 2012-01-10
  • 1970-01-01
  • 2013-07-26
相关资源
最近更新 更多