Credit
Huge thanks to our very own email ninja, Stig for making this tool. Say thanks @stigm
Use rock-solid background images in your HTML email with some help from VML and CSS. Why not do the same with our bulletproof button generator?
If you're still having trouble, feel free to email support@campaignmonitor.com your full template/campaign files, as well as a screenshot showing the issue clearly in the relevant email client(s).
Unfortunately, these background images and buttons can not be placed on top of other background images, because Outlook doesn't support nested VML elements. In many cases though, you may be able to code the design up successfully by changing the structure.
For instance, if only part of the image needs to be behind text content, you can sometimes slice the image, use a bulletproof background image for only that part of the design, and use bulletproof buttons or inline images (held together by a table structure) for other parts.
Because Outlook doesn't support @media queries, you only need to worry about the email clients that do. So only the HTML element needs to be responsive, not the VML. As a general recommendation, using mostly pixel based widths in the HTML is more reliable, and you can then override this with other pixel or percentage based widths for other viewports like with any responsive web design.
To get started, give your background image table cell a class or ID that you can target. Then in any appropriate @media queries, give the table cells different dimensions, background images, etc.
This technique can only add repeating background images to your emails. But depending on your design, you may be able to solve this by using a fixed pixel height, width, or both. Or in some cases, adding more space around the image file itself might help.
Full email width backgrounds in Outlook are based on the mso-width-percent property, since percentage based values don't work with the regular width property. Unfortunately there are a few Outlook 2007/2010/2013 bugs that affect this technique.
Outlook forces a minimum body margin on all HTML emails. And if you set a VML element to "mso-width-percent: 1000" (100% width), it bases the rendered width on the full email/viewport width, while still adding 10px margins on each side. So if you center content inside full width background image tables, it can offset that content 10px to the right, and also cause horizontal scrolling.
You can experiment with reducing the mso-width-percent to somewhere around 960-980 to avoid scrolling, but alignment will still depend on the width of the viewport.
Unlike most other email clients and browsers, Outlook 2007/2010/2013 uses the DPI of your background image to determine the scale. So to make sure it renders at the right size, set the image's resolution to 96 DPI.
You can place a table inside the background image cell, around your content, and add table rows and columns with height and width equal to the spacing you'd like to add. In some cases, a better option can be to slice the image, and only use a background image for the table cell that will have the content. The surrounding cells can have the rest of the design as inline image tags, text or plain background colors, depending on the design.
To set the vertical alignment of your content, you can change the table cell's valign attribute to middle or bottom, and add style="v-text-anchor:middle" or style="v-text-anchor:bottom" to the <v:textbox>
tag.
To center the content horizontally, you can replace the <div>
tag with <center>
. Right aligning the content can be done with <p align="right">
, but this can result in some unwanted spacing. Another option is to place a one-cell table inside the background image cell, give this cell the same width as the background image, and add <align="right">
.
This has to do with Outlook always expecting a paragraph inside VML elements (and inserting them if there isn't one). But to work around the issue, you can add the line <p style="margin:0;mso-hide:all"><o:p xmlns:o="urn:schemas-microsoft-com:office:office"> </o:p></p>
right before the closing </v:textbox>
tag, and the gap should be no more.
Unfortunately, background images have to be hard coded into your template or campaign for now. You can however use a
If you’d like to see this feature added to the editor, make your voice heard in our forums or by email.