将简讯发送到 Gmail,其中包含带有背景图片的 div
我可以向电子邮件帐户发送新闻通讯。我使用 div 来包含文本。现在,我想为 div 设置背景图像,如下面的代码所示:
string containerDiv = @"<div width=200 height=500 style=""background:url('http://www.instantfetch.com/Content/restaurant_logos/promo1.gif');"">";
但问题是,我的 Yahoo 帐户可以获取其正文中的图像,但我的 Gmail 帐户却不能。下面是两个屏幕截图: 我使用 Google Chrome 中的“检查元素”选项在浏览器中获取渲染的 div。
雅虎:
邮箱:
我的问题是我的代码有什么问题?为什么 Yahoo 可以正确获取 URL 并渲染,而 Gmail 却无法获取 URL 且无法渲染?如果我想在 Gmail 中也显示背景图片,该怎么办?
I can send newsletters to email accounts. I am using div for containing the text. Now, I want to set a background image to the div as demonstrated in the code below:
string containerDiv = @"<div width=200 height=500 style=""background:url('http://www.instantfetch.com/Content/restaurant_logos/promo1.gif');"">";
But the problem is, my Yahoo account can fetch the image in its body but my Gmail account cannot. Below are two screenshot: I used 'Inspect element' option in Google Chrome to get the rendered div in my browser.
Yahoo:
Gmail:
My question is what is the problem in my code? Why can Yahoo get the URL properly and render it but Gmail cannot get the URL and cannot render it? What should I do if I want to display the background image in Gmail as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Gmail 不支持背景图片。
它在这里产生了很多问题,并由于限制而导致重新设计。这不是您的代码...而是 Gmail。
Gmail does not support background images.
It's created many problems here and caused redesign due to the limitation. It's not your code... it's Gmail.
您缺少“background:url”后面的括号。
应该是
style=""background:url('http://www.instantfetch.com/Content/restaurant_logos/promo1.gif');""
我想雅虎忽视了你的错误。
You are missing the bracket after "background:url".
Should be
style=""background:url('http://www.instantfetch.com/Content/restaurant_logos/promo1.gif');""
I guess Yahoo is overlooking your mistake.
“”可能是导致问题的原因。试试这个:
The "" might be causing the issue. Try this: