Outlook忽略Width属性或CSS属性 [英] Outlook Ignores Width attribute or css property

查看:477
本文介绍了Outlook忽略Width属性或CSS属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到很多问题都涉及到这个问题,但是没有一个具体的问题可以帮助我.因此,我希望如果我简化并再次询问,不会冒犯任何人.希望源源不断!

I've seen this problem touched on in many questions but none have been specific enough to help me. So I hope it offends no one if I simplify it and ask again. Hope springs eternal!

在Outlook渲染电子邮件时,控制嵌入在电子邮件中的图像的宽度真的是不可能的吗? IE.控制html代码为

Is it really IMPOSSIBLE to control the width of an image embeded in an email when Outlook renders it? I.e. control the width of an image for which the html code is

 <img src="cid:seal">

即当html代码需要嵌入的图像而不是存储在其他位置的图像时.

I.e. when the html code expects an embedded image instead of one stored elsewhere.

[注意:印章"是我在创建带有嵌入式图像的MimeBodyPart时分配的内容ID.

[Note: "seal" is the content ID I assigned when creating the MimeBodyPart with the embedded image].

详细信息: 我使用Javamail应用程序发送多部分电子邮件.正文部分是一个html文档.另一个MimeBodyPart带有html文档中使用的图像.我已经将html测试简化为只有两列的表格,其中图像的左列和文本的右列.

Details: I use a Javamail application to send a multi-part email message. The body part is an html document. Another MimeBodyPart carries the image used in the html doc. I've simplified the html test to nothing more than a two column table with the left column for the image and the right column for text.

在OUTLOOK中打开时,我尝试过的绝对没什么能控制图像的大小.

And absolutely NOTHING I have tried has been able to control the size of the image when opened in OUTLOOK.

我一直认为图像始终是图像的原始尺寸...太大了...所以它迫使第一个像元的宽度超过15%.或者,如果我为单元格设置了固定的宽度,则图像会溢出框,即被裁剪.

The image is always what I assume must be some native size for the image ... which is too big ... so it forces the first cell to be more than 15% wide. Or if I give the cell a fixed width the image overflows the box, i.e. get's clipped.

我在下面放掉了所有字体样式颜色等的基本代码.

I put the basic code stripped of all font styling colors etc. below.

我尝试了在img标签上使用width属性和css style属性的每种组合.我已经将图像包装在另一个表中……或将其包装在主表单元格中的div块中……甚至将其包装在父表单元格中的一个表单元格中的div块中.而且我尝试指定固定像素和%的宽度.

I have tried every combination of using width attributes and css style properties on the img tag. I've wrapped the image in another table ... or wrapped it in a div block inside the main table cell ... and even wrapped it in a div block inside a table cell inside the parent table cell. And I've tried specifying widths in fixed pixels and %'s.

如果我们所有人都知道Outlook是否根本不可能,那就太好了.

It would really be nice if we all knew for sure if this is simply IMPOSSIBLE with Outlook.

或者,如果可能的话,发布有效的示例代码. [让电子邮件立即打开其图像,而不依赖于读者下载它们,这非常具有吸引力.]

Or if it is possible possible, to publish sample code that works. [It's hugely attractive to have the email open its images immediately, and not rely on the reader downloading them.]

注意:当我以后从外部来源加载图像时,我似乎能够控制宽度,即 谢谢你的帮助.

NOTE: I seem able to control width when I load the image from an outside source afterwards, i.e. Thanks for any help.

<html>
  <head>
    <meta name="viewport" content="width=980, initial-scale=1">
    <title>Test Email</title>
  </head>
  <body style="width:100%; border:0;margin:0;padding:0;">
    <table align="center" 
           style="width:980px; border-collapse:collapse;
                  margin-left:auto; margin-right:auto;">
      <tr  style="border:0; margin:0; padding:0;">
        <td style="width:15%; border:0; margin:0; padding:0;">
          <img src="cid:seal" 
               style="width:6em; height:auto;">
         </td>
         <td    style="width:85%; margin:0; padding:.5em 0em 0em 0em; border:0;">
           Some Titles and stuff
         </td>
       </tr>
  <tr>
    <td colspan="2" style="border:0; margin:0; padding:1em 1em 0em .5em;">
      <p> 1st paragraph
      ....
      <p> last paragraph
    </td>
  </tr>
</table>

推荐答案

Outlook使用Word作为电子邮件编辑器.以下系列文章提供了与受支持和不受支持的HTML元素,属性以及级联样式表属性有关的参考文档:

Outlook uses Word as an email editor. The following series of articles provides reference documentation related to supported and unsupported HTML elements, attributes, and cascading style sheets properties:

  • Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007 (Part 1 of 2)
  • Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007 (Part 2 of 2)

您可以在Word中设计页面,然后将结果文档另存为网页.因此,您将找到需要使用的HTML标记.

You can design the page in Word and then save the resulted document as a web page. Thus, you will find the required HTML markup to use.

这篇关于Outlook忽略Width属性或CSS属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆