繁体   English   中英

回声背景图像

[英]echo background-image

我正在尝试在.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将此代码验证为正确,但图像未显示在发送的电子邮件中。

<?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属性的值由双引号括起来,因此必须对内部的任何双重配额进行转义。

你需要改变这个:

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,导致它误读。

你的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 =“”属性中,所以背景图像行中的符号表示样式属性的结尾而不是图像的路径。

尝试使用单个转义引号,如图像的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>
'
?>

其他答案都没有解决问题(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>
    '; ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM