Html Outlook 邮件中未采用图像样式的高度和宽度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20989897/
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
Image style height and width not taken in outlook mails
提问by Milind Anantwar
I have a following dom structure in html content I am sending as email.
我在作为电子邮件发送的 html 内容中有以下 dom 结构。
<a href="http://content.mindmatrix.net/email/814xjqjmpj5r/b59tqx7tzz2x7"
target="_new">
<span style='text-decoration:none;text-underline:none'>
<img border=0 id="_x0000_i1026"
src="http://dev.mindmatrix.net/page/e7c9cf53-bae8-4024-a561-355f950cb26b/635246986810000000/original.jpeg?userid=cozmwz91irkm1"
style='border-bottom-color:black;border-bottom-style:solid;border-bottom-width:
1px;border-left-color:black;border-left-style:solid;border-left-width:1px;
border-right-color:black;border-right-style:solid;border-right-width:1px;
border-top-color:black;border-top-style:solid;border-top-width:1px;
height:150px;width:120px'>
</span></a>
I am giving style height:150px;width:120px
to image for making it of size thumbnail. Actual height and width of this image is very large. Problem is, this style is not taken when mail goes in outlook inbox. So my questions are -
我正在height:150px;width:120px
为图像赋予样式以使其成为大小缩略图。此图像的实际高度和宽度非常大。问题是,当邮件进入 Outlook 收件箱时,不会采用这种样式。所以我的问题是——
1)How can i make the css work for setting height and width.
1)如何让 css 用于设置高度和宽度。
2) Image appears blur in Windown live mail. I am not sure whether it will persist in outlook when i will succeed in fixing style of height and width. so how can i fix this
2) Windown live mail 中图像模糊。我不确定当我成功固定高度和宽度的样式时,它是否会持续存在。那么我该如何解决这个问题
回答by Anup
Put the width and height in separate attributes, with no unit:
将宽度和高度放在单独的属性中,没有单位:
<img style="margin: 0; border: 0; padding: 0; display: block;"
src="images/img.jpg" width="120" height="150">
Another Option:
另外一个选项:
<!--[if gte mso 9]>
<style type="text/css">
img.header { width: 600px; } /* or something like that */
</style>
<![endif]-->
回答by Ela
This worked for me:
这对我有用:
src="{0}" width=30 height=30 style="border:0;"
Nothing else has worked so far.
到目前为止,没有其他任何工作。
回答by Paul
The px needs to be left off, for some odd reason.
由于某些奇怪的原因,需要关闭 px。
回答by Joakim Ling
Can confirm that leaving px out from width and height did the trick for Outlook
可以确认从宽度和高度中删除 px 对 Outlook 起到了作用
<img src="image.png" style="height: 55px;width:139px;border:0;" height="55" width="139">
回答by mable george
<img id="_x0000_i1026" src="images/img.jpg" width="120" height="150" />
This worked for me both in gmail and outlook.
这在 gmail 和 Outlook 中都对我有用。
回答by Jay
I had the pleasure of creating an email for outlook 2010 based on sharepoint data. But when creating an outlook email, outlook in its wisdom reduces the imga ewidth and height to cm. interestingly using the width and height kicks in correctly when you forward the email but not when you open it.
我很高兴根据共享点数据为 Outlook 2010 创建电子邮件。但是在创建 Outlook 电子邮件时,Outlook 的智慧是将图像宽度和高度减少到厘米。有趣的是,当您转发电子邮件时正确使用宽度和高度,但在打开电子邮件时则不会。
hack fix.
黑客修复。
i had an image 720px X150px which should be 19.05cm x 3.98cm . BUT outlook set the image width and height to (15.24cm X 3.18cm). *clearly this is a problem.
我有一个 720px X150px 的图像,应该是 19.05cm x 3.98cm 。但是 Outlook 将图像宽度和高度设置为 (15.24cm X 3.18cm)。*显然这是一个问题。
the hack i used was setting the html image tag as follows
我使用的 hack 是按如下方式设置 html 图像标签
<img src="...." style="width:720px;heigh:150px" width="900" height="187.5" />
why that width and height; well its the ratio (25% increase) between what outlook was saying and what it should be (720 X 25% = 900). Its not pretty but it works.
为什么那个宽度和高度;好吧,它是前景所说的和应该是的(720 X 25% = 900)之间的比率(增加了 25%)。它不漂亮,但它有效。
回答by gjseminario
This works for me in Outlook:
这在 Outlook 中对我有用:
<img src="image.jpg" width="120" style="display:block;width:100%" />
<img src="image.jpg" width="120" style="display:block;width:100%" />
I hope it works for you.
我希望这个对你有用。
回答by Vishvanathsinh Solanki
I have same problem for image which is not showing correctly in outlook.and I am using px and % for applying height and width for image. but when i removed px and % and using only just whatever the value in html it is worked for me. For example i was using : width="800px" now I'm using widht="800" and problem is resolved for me.
我有同样的问题,它在 Outlook 中没有正确显示。我使用 px 和 % 来应用图像的高度和宽度。但是当我删除 px 和 % 并且只使用 html 中的任何值时,它对我有用。例如,我正在使用:width="800px" 现在我正在使用 widht="800" 并且问题已为我解决。