HTML 电子邮件对齐文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9989657/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 23:29:39  来源:igfitidea点击:

HTML email align text

htmlemailhtml-email

提问by user1299846

I am trying to align a part of text to the right and the other part to the left in an HTML mail but in Outlook the floatdoesn't work. So basically I am looking for floatCSS in Outlook. I know it sounds pretty creepy and text-alignor align=""didn't work. Any suggestions?

我试图在 HTML 邮件中将文本的一部分向右对齐,另一部分向左对齐,但在 Outlookfloat中不起作用。所以基本上我float在 Outlook 中寻找CSS。我知道这听起来很令人毛骨悚然,text-align或者align=""没有用。有什么建议?

<td>
   <span style="text-align:left; float:left;">
       First part
   </span>
   <span style="text-align:right; float:right;">
       Second part
   </span>
</td>

回答by SpaceBeers

Honestly if you're doing an HTML email I'd stick to using tables. Not all CSS selectors are available in all email clients and you'll drive yourself mad trying to do it any other way. HTML emails are like the web 5 years ago.

老实说,如果您正在处理 HTML 电子邮件,我会坚持使用表格。并非所有的电子邮件客户端都可以使用所有 CSS 选择器,如果您想以任何其他方式这样做,您会发疯。HTML 电子邮件就像 5 年前的网络。

There are a couple of good documents on the subject:

有几个关于这个主题的好文件:

http://www.campaignmonitor.com/css/

http://www.campaignmonitor.com/css/

http://www.emailology.org/

http://www.emailology.org/

For your example:

对于您的示例:

<td>
   <table cellpadding="0" cellspacing="0" width="100%">
       <tr>
           <td align="left">First part</td>
           <td align="right">Second part</td>
       </tr>
   </table>
</td>

It's horrible but unfortunately it's still the best way.

这很可怕,但不幸的是,它仍然是最好的方法。

回答by Quentin

Use (shudder) layout tables.

使用(颤抖)布局表。

Outlook's support for styling of email is so awful that there isn't any other way.

Outlook 对电子邮件样式的支持是如此糟糕,以至于没有其他方法。

There is a 24 ways articlewith some general advice for writing HTML formatted email.

一篇关于编写 HTML 格式电子邮件的24 种方法的文章,其中包含一些一般性建议。

回答by Alice Girard

<p align="right">My right content</p>

It should do the trick as it is HTML1.

它应该可以解决问题,因为它是 HTML1。