html - 如何制作没有文本的完整背景图像电子邮件?

标签 html css background-image

我想知道即使没有文本,如何使背景在电子邮件中显示为全宽。我不知道如何让它出现,即使没有你能看到的文字和它的实际尺寸。我希望结果类似于底部的文本,如页脚。 有人知道怎么做吗?

enter image description here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:v="urn:schemas-microsoft-com:vml">

<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" />
  <title></title>
</head>

<body>
  <title></title>

  <div class="email-background" style="padding:10px;background:white;">
    <div class="pre-header" style="background:white;font-size:5px;color:white;text-align:left;max-width:500px;">
    </div>
    <!--BODY-->
    <div class="email-container" style="background:white;font-family:Varela Round,arial, sans-serif;color:#03165c;margin:0 auto;max-width:100%;">
      <table class="contenu" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="white">
        <tr>
          <td height="1" style="font-size:1;line-height:1;background:#374b94;">&#160;</td>
        </tr>
        <tr>
          <td valign="top" bgcolor="#374b94" background="https://image.noelshack.com/fichiers/2017/51/4/1513863465-carte2.png" style="background-repeat:no-repeat;background-size:contain;background-position: center; ">
            <!--[if !gte mso 9]><!---->
            <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false">
              <v:fill type="tile" src="https://image.noelshack.com/fichiers/2017/51/4/1513863465-carte2.png" color="#374b94">
                <v:textbox inset="0,0,0,0">
                  <!--<![endif]-->
                  <tr>
                    <td>
                      <p align="left" style="font-family:Varela Round,arial, sans-serif;color:#c6c9dc;font-size:10px;">
                        Si vous ne souhaitez plus recevoir d'email cliquez <a class="unsubscribe" href="mailto:desinscription@marketing-idxcel.fr?subject=Désinscription&body=Je%20souhaite%20ne%20plus%20recevoir%20de%20mail%20de%20votre%20part" style="color:#c6c9dc;text-decoration:underline #c6c9dc;">ici</a>

                      </p>

                    </td>

                  </tr>
                  <!--[if !gte mso 9]><!---->
                </v:textbox>
            </v:rect>
            <!--<![endif]-->
          </td>

        </tr>
      </table>
    </div>
    <!--/BODY-->
  </div>
</body>

</html>

最佳答案

为图像样式添加高度。如果您检查它,您会发现它只有宽度。

    background-repeat:no-repeat;
    background-size:contain;
    background-position: center;
    height: 500px;

    /** or padding: some value **/
    padding-bottom: 40%;

关于html - 如何制作没有文本的完整背景图像电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47926580/

相关文章:

html - 响应式设计定位跨度

html - Wordpress 媒体文件 - 将鼠标悬停在图像上

jquery - CSS 图像叠加未到达侧面

CSS左,右div背景问题

javascript - 随机背景更改仅适用于 Firefox?

javascript - 如何让文字环绕成圆形?

javascript - 在 Ajax 响应中加载 HTML

javascript - 背景上的谷歌广告视差

javascript - 当内容达到一定大小时出现空白页

css - 具有相同图像的多个背景