【问题标题】:Define a css to get background-image from Linked Resources定义一个 css 以从链接资源中获取背景图像
【发布时间】:2014-03-29 02:46:26
【问题描述】:

如何告诉我的 css 代码背景图像的来源是 LinkedResource ?

将其添加为 <img src="cid:Photo0" /> 有效,但我无法按照我想要的方式设置它。

我试过这个 css background-image:'cid:Photo0' 这个 background-image:url('cid:Photo0') 和其他引号和双引号的组合,但是链接的资源将以这种方式显示为附件,并且带有这个 css 代码的 div 要么缺少背景-图像或有时看起来像这样:

<DIV cid:Photo0?);margin:70px0px;padding:0px0px;background-attachment:fixed;background-repeat:no-repeat;text-align:center;margin:auto;?="">

原来是这样写的:

<div style="background-image:'cid:Photo0';margin:70px 0px;padding: 0px 0px;background-attachment:fixed;background-repeat:no-repeat;text-align:center;margin:auto; ">

【问题讨论】:

    标签: c# css smtpclient


    【解决方案1】:

    试试这个:

    <div style="background-image: url(cid:Photo0);margin:70px 0px;padding: 0px 0px;background-attachment:fixed;background-repeat:no-repeat;text-align:center;margin:auto;" />
    

    这个答案正在修复 CSS,但似乎仍然存在问题,这是一个相关线程:Embedding background images in an e-mail

    编辑:

    经过小型头脑风暴和讨论,css 似乎不支持此功能,而且大多数查看电子邮件的应用程序无论如何都无法正确呈现某些 css。

    【讨论】:

    • 我试过了,没用,效果如下:&lt;div style="" cid:Photo0?);margin:70px0px;padding:0px0px;background-attachment:fixed;background-repeat:no-repeat;text-align:center;margin:auto;?=""&gt;
    • &lt;div style="" cid:Photo0?);margin:70px0px;padding:0px0px;background-attachment:fixed;background-repeat:no-repeat;text-align:center;margin:auto;?=""&gt;
    • 如果&lt;img src="cid:{0}" /&gt; 工作cid:{0} 必须包含图像的网址。 iL## 更新我的答案
    • 那么您是否尝试过不带引号的解决方案?您要么不使用引号,要么为 background-image: url(); cid:Photo0 使用引号,而诅咒必须将其解析为所需的 url。
    • 也没有用,它像附件一样,虽然 html 中有 div &lt;div style="width: 85px; height: 85px; background-image: url("cid:Photo0");"/&gt;,但它没有显示背景
    【解决方案2】:

    我找到的最佳解决方案是:

    style="background:url(data:image/jpg;base64,{CONTENT-BASE64})"
    
    • 如果图像不是 JPEG,请更改“image/jpg”以适合图像格式。
    • 将 {CONTENT-BASE64} 替换为 Base64 中的图像文件内容。

    【讨论】:

    • 问题不在于显示图像,而是在发送的电子邮件中与其关联的 CSS。大多数 CSS 标记在电子邮件消息中不起作用或无法正常工作。但是谢谢,我会试试你建议的解决方案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-04
    • 1970-01-01
    • 1970-01-01
    • 2019-10-08
    • 2015-09-09
    • 1970-01-01
    • 2011-08-07
    相关资源
    最近更新 更多