简体   繁体   English

使用VML将背景图像应用于表格单元格

[英]Applying background Image to table cell with VML

I am trying to apply a repeating background to a table cell for an html email, I am using the code from http://backgrounds.cm/ 我正在尝试将重复的背景应用于HTML电子邮件的表格单元格,我正在使用http://backgrounds.cm/中的代码

Here is my TD and wrapper VML: 这是我的TD和包装器VML:

<td background="http://domain.com/Portals/0/emails/images/stripes-middle.png" bgcolor="#00ff00" width="346" valign="top">
  <!--[if gte mso 9]>
  <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:346px;">
    <v:fill type="tile" src="http://domain.com/Portals/0/emails/images/stripes-middle.png" color="#ff0000" />
    <v:textbox style="mso-fit-shape-to-text:true" inset="0,0,0,0">
  <![endif]-->
  <div>
      <p>LOTS OF CONTENT IN HERE</p>                                                                
  </div>
  <!--[if gte mso 9]>
    </v:textbox>
  </v:rect>
  <![endif]-->
</td>

However, it is renderring my background image up in the top left of the parent table! 但是,它在父表的左上角渲染了我的背景图像! Not within the table cell. 不在表格单元格内。 How can I fix this? 我怎样才能解决这个问题?

why not nest it in another table then? 为什么不将其嵌套在另一个表中呢?

<table border="0" cellpadding="0" cellspacing="0" width="640" style="border-collapse:collapse; padding:0; margin:0px;">
<tr valign="top">
    <td align="center" valign="top">
        <table border="0" cellpadding="0" cellspacing="0" width="346" style="border-collapse:collapse; padding:0; margin:0px;">
            <tr valign="top">
                <td background="http://domain.com/Portals/0/emails/images/stripes-middle.png" bgcolor="#ff0000" width="346" height="112" valign="top">
                    <!--[if gte mso 9]>
                    <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false"   style="width:346px;height:112;">
                    <v:fill type="tile" src="http://domain.com/Portals/0/emails/images/stripes-middle.png" color="#ff0000" />
                    <v:textbox inset="0,0,0,0">
                    <![endif]-->
                    <div>
                        <table border="0" cellpadding="0" cellspacing="0" width="346" style="border-collapse:collapse; padding:0; margin:0px;">
                            <tr valign="top">
                                <td align="left" valign="top">
                                    <p>LOTS OF CONTENT IN HERE</p>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <!--[if gte mso 9]>
                    </v:textbox>
                    </v:rect>
                    <![endif]-->
                </td>
            </tr>
        </table>
    </td>
</tr>
</table>

can't pinpoint exactly where you're going wrong, but I've never used fit-shape-to-text before and this snippet hasn't done me wrong. 无法确切指出您要去哪里,但我以前从未使用过适合形状到文本的功能,并且此代码片段并没有给我带来错误。

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

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