0

我正在尝试在 a 中回显背景图像.phtml以发送电子邮件。

但是我在引用时遇到了麻烦。图像未显示。

<?php echo '
    Plataforma <a href="http://xxxx.com/">http://xxxx.com/</a>
    <br>
    <div style="width:220px; height:30px; background-color:black; background-repeat: no-repeat; background-image:url("http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg")"></div>
'
?>

IDE 验证此代码是否正确,但图像未显示在发送的电子邮件中。

4

5 回答 5

1
<?php echo '
    Plataforma <a $href="http://xxxx.com/">http://xxxx.com/</a>
    <br>
    <div $style="width:220px; height:30px; background-color:black; background-repeat: no-repeat; background-image:url(\"http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg\")"></div>
    '
?>

style 属性的值用双引号括起来,所以里面的任何双引号都必须转义。

于 2012-10-25T11:58:48.723 回答
1

你需要改变这个:

background-image:url("http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg")

到:

background-image:url('http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg')

双引号在错误的地方切断了你的 DOM,导致它被误读。

于 2012-10-25T11:59:03.830 回答
0

您的 CSS 无效。更改此行:

background-image:url("http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg")

像这样阅读:

background-image:url('http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg')

因为它在 style="" 属性中,所以 background-image 行中的 " 符号表示样式属性的结束,而不是图像的路径。

于 2012-10-25T11:58:33.457 回答
0

尝试使用单转义引号,例如在图像的 URL 中:

<?php echo '
    Plataforma <a href="http://xxxx.com/">http://xxxx.com/</a>
    <br>
    <div style="width:220px; height:30px; background-color:black; background-repeat: no-repeat; background-image:url(\'http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg\')"></div>
'
?>
于 2012-10-25T11:59:36.367 回答
0

其他答案都没有解决这个问题(gmail、hotmail)。这将起作用

<?php echo '
    Plataforma <a href="http://xxxx.com/">http://xxxx.com/</a>
    <br>
    <div style="width:220px; height:30px; background-color:black;">
        <img src="http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg">
    </div>
    '; ?>
于 2012-10-25T13:17:35.910 回答