in my Django app I would like to put a background image in a table. The problem is that the image doesn't show. This is the code:
<table style="background-image: url('/static/assets/img/myimage.png') ;background-position: 0 100% !important;background-repeat: repeat-x ;background-size: 40px 3px">
Hello!
</table>
If I put the same css style in div object all work. Eg:
<div style="background-image: url('/static/assets/img/myimage.png') ;background-position: 0 100% !important;background-repeat: repeat-x ;background-size: 40px 3px">
Hello!
</div>
Where is my mistake? Thanks a lot for the help
EDIT1
I would like to insert a email html file in a django template. I use 'include' and all works for image but doesn't works for background-image style. The image location is correct (if I use 'div' and not 'table' all works). I have bootstrap
EDIT2
This the complete code. In the table I don't see the background image
<!-- ======= section ======= -->
<table border="0" width="100%" cellpadding="0" cellspacing="0" bgcolor="34302d" style="background-image: url('http://themastermail.com/envato/omail/demo/layout2/img/testi-bg.jpg') !important; background-size: cover; background-position: top center; background-repeat: no-repeat;" background="http://themastermail.com/envato/omail/demo/layout2/img/testi-bg.jpg">
<tr><td height="60" style="font-size: 60px; line-height: 60px;"> </td></tr>
<tr>
<td align="center">
<table border="0" width="590" align="center" cellpadding="0" cellspacing="0" class="container590">
<tr>
<td>
<table border="0" width="580" align="center" cellpadding="0" cellspacing="0" class="container580">
<tr>
<td align="center" style="color: #b9bcc7; font-size: 16px; font-family: 'Open Sans', Calibri, sans-serif; line-height: 30px;" class="title_color">
<!-- ======= section text ====== -->
<div style="line-height: 30px">
<em>Proin eget massa tincidunt, lobortis ex nec, placerat odio. Mauris gravida nulla id laoreet ornare. Maecenas sagittis elit metus, eget pellentesque couleur non categorize rouge vert bleu.</em>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr><td height="35" style="font-size: 35px; line-height: 35px;"> </td></tr>
<tr>
<td align="center">
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" width="80">
<img src="http://themastermail.com/envato/omail/demo/layout2/img/testi-img.png" style="display: block; width: auto;" width="70" border="0" alt=""/>
</td>
<td align="left" style="color: #ffffff; font-size: 14px; font-family: Raleway, Calibri, sans-serif; mso-line-height-rule: exactly; line-height: 24px;" class="title_color">
<!-- ======= section header ======= -->
<div style="line-height: 24px;">
Marta Clarcks<br>envato.com
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr><td height="60" style="font-size: 60px; line-height: 60px;"> </td></tr>
</table>
<!-- ======= end section ====== -->
You left out the ! on your !important tag.
<table style="background-image: url('/static/assets/img/myimage.png') !important;background-position: 0 100% !important;background-repeat: repeat-x !;background-size: 40px 3px">
Hello!
</table>
but as you've not got a tr, td etc in your field it may still not display it, you should try:
<table style="background-image: url('/static/assets/img/myimage.png') !important;background-position: 0 100% !important;background-repeat: repeat-x !;background-size: 40px 3px; display: block;">
<tr>
<td>
<p>hello</p>
</td>
</tr>
</table>
try this
<table style="background-image: url('static/assets/img/myimage.png') !important;background-position: 0 100% !important;background-repeat: repeat-x !;background-size: 40px 3px">
<tr><td>Hello!</td></tr>
</table>
folder structure
css.css
static/
Related
I'm using the image as a background in my HTML-email, to get the ability to allocate text and button over the top layer of the image and it is working fine for every email client beside the MS Outlook 2013 on Windows 7.
For some reason, once the user got the email and click on the button (or wherever image area) there is weird frame appears around the image and that frame looks like user can edit that image (rotate or resize), but he can't, it's just a frame.
I can't figure out how can I get rid of that frame. Another problem is the Litmus doesn't show any issue with the code so it's kina like impossible to fix without actual sending. Please help!
Using all header as one image isn't an option because the client requires the ability to change the text over himself.
Below the part of the code for the header only but here is the link on the code of the entire email https://pastebin.com/edYR2eVm and the Litmus project https://litmus.com/builder/da4ef27
<!-- HERO : BEGIN -->
<tr>
<!-- Bulletproof Background Images c/o https://backgrounds.cm -->
<td background="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSYiUYrvVY_LbHtpJf-iiBrk_3BXOwqHyulAj0sDk3gJKOxAl6FkA" bgcolor="#222222" align="center" valign="top" style="text-align: center; background-position: center center !important; background-size: cover !important;">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:680px; height:380px; background-position: center center !important;">
<v:fill type="tile" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSYiUYrvVY_LbHtpJf-iiBrk_3BXOwqHyulAj0sDk3gJKOxAl6FkA" color="#222222" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<div>
<!--[if mso]>
<table role="presentation" border="0" cellspacing="0" cellpadding="0" align="center" width="500">
<tr>
<td align="center" valign="middle" width="500">
<![endif]-->
<table role="presentation" border="0" cellpadding="0" cellspacing="0" align="center" width="100%" style="max-width:500px; margin: auto;">
<tr>
<td height="20" style="font-size:20px; line-height:20px;"> </td>
</tr>
<tr>
<td align="center" valign="middle">
<table>
<tr>
<td valign="top" style="text-align: center; padding: 60px 0 10px 20px;">
<h1 style="margin: 0; font-family: 'Montserrat', sans-serif; font-size: 30px; line-height: 36px; color: #ffffff; font-weight: bold;">WELCOME %%FIRST NAME%%</h1>
</td>
</tr>
<tr>
<td valign="top" style="text-align: center; padding: 10px 20px 15px 20px; font-family: sans-serif; font-size: 15px; line-height: 20px; color: #fff;">
<p style="margin: 0;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore.</p>
</td>
</tr>
<tr>
<td valign="top" align="center" style="text-align: center; padding: 15px 0px 60px 0px;">
<!-- Button : BEGIN -->
<center>
<table role="presentation" align="center" cellspacing="0" cellpadding="0" border="0" class="center-on-narrow" style="text-align: center;">
<tr>
<td style="border-radius: 50px; background: #26a4d3; text-align: center;" class="button-td">
<a href="http://www.google.com" style="background: #26a4d3; border: 15px solid #26a4d3; font-family: 'Montserrat', sans-serif; font-size: 14px; line-height: 1.1; text-align: center; text-decoration: none; display: block; border-radius: 50px; font-weight: bold;" class="button-a">
<span style="color:#ffffff;" class="button-link"> ACCESS ACCOUNT </span>
</a>
</td>
</tr>
</table>
</center>
<!-- Button : END -->
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="20" style="font-size:20px; line-height:20px;"> </td>
</tr>
</table>
<!--[if mso]>
</td>
</tr>
</table>
<![endif]-->
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
<!-- HERO : END -->
I'm working on a responsive email template and can't get some divs to center on mobile as they should.
I have media queries included in the CSS to center the content on mobile, but they are being ignored on the second div. Not sure if I have the media query styles in the right places in the code. Media queries and div code included for reference.
/*Responsive screens*/
#media screen and (max-width: 500px) {
.stack-column, .stack-column-center { display: block !important;width: 100% !important;max-width: 100% !important;direction: ltr !important; padding-left:0px !important; padding-right:0px !important; padding-bottom:0px !important } /*Forces table cells into full-width rows*/
.stack-column-center { text-align: center !important; padding-left:0px !important; padding-right:0px !important; } /* And center justify these ones. */
.center-on-narrow { text-align: center !important;display: block !important;margin-left: auto !important;margin-right: auto !important;float: none !important; } /*Generic utility class for centering. Useful for images, buttons, and nested tables*/
table.center-on-narrow { display: inline-block !important; }
.email-container p { font-size: 17px !important; } /*Adjusts typography on small screens to improve readability*/
.middle-article-mobile-pt { padding-top: 60px !important; }
.middle-article-mobile-pb { padding-bottom: 60px !important; }
}
<tr>
<td dir="ltr" height="100%" style="padding: 30px 50px; background-color: #ffffff;" valign="top" width="100%"><!--[if mso]>
<table align="center" role="presentation" border="0" cellspacing="0" cellpadding="0" width="500" style="width: 500;">
<tr>
<td valign="top" width="500" style="width: 500;">
<![endif]-->
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="max-width:500px; padding:0; margin:0;" width="100%">
<tbody>
<tr style="padding:0;margin:0;">
<td align="center" style="font-size:0; padding: 0;" valign="top" class=""><!--[if mso]>
<table role="presentation" border="0" cellspacing="0" cellpadding="0" width="500" style="width: 500;">
<tr>
<td valign="top" width="200" style="width: 200px;">
<![endif]-->
<div class="stack-column" style="display:inline-block; margin: 0; max-width: 200px; vertical-align:top; width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody>
<tr>
<td dir="ltr" style="padding: 0 10px 0 10px;" class=""><img alt="alt_text" border="0" class="center-on-narrow" height="" src="http://go.pardot.com/l/190862/2019-04-09/h9rldk/190862/77786/template_testing_200px_placeholder.png" style="width: 100%; max-width: 200px; height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; line-height: 15px; color: #555555;" width="200"></td>
</tr>
</tbody>
</table>
</div>
<!--[if mso]>
</td>
<td valign="top" width="300" style="width: 300px;">
<![endif]-->
<div class="stack-column" style="display:inline-block; margin: 0; max-width:300px; vertical-align:top;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody>
<tr>
<td class="center-on-narrow" dir="ltr" style="font-family: sans-serif; font-size: 15px; line-height: 20px; color: #555555; padding: 0 0 0 20px; text-align: left;">
<p class="body-h1" style="margin:0;">Headline</p>
<p class="body-h2" style="margin:0;"><a href="##" style="text-decoration:underline;">Author, CPA<br>
Title title title title</a></p>
<p class="body-copy" style="margin: 15px 0;">Maecenas sed ante pellentesque, posuere leo id, eleifend dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>
<!-- Button : BEGIN -->
<table align="left" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td align="left" bgcolor="#05090c7" pardot-data="" style="border-radius: 2px; background: rgb(255,255,255);" class=""><a class="light-blue-button" href="##"><!--[if mso]> <![endif]-->Read the Article <!--[if mso]> <![endif]--></a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!-- Button : END --></td>
</tr>
</tbody>
</table>
</div>
<!--[if mso]>
</td>
</tr>
</table>
<![endif]--></td>
</tr>
</tbody>
</table>
<!--[if mso]>
</td>
</tr>
</table>
<![endif]--></td>
</tr>
Was expecting the .center-on-narrow and .stack-column CSS styles to center the div content on narrow but it's being ignored on the second div.
Try using center tags. This will center the content enclosed by the tags. For an example visit Center Tags Example.
I figured this out! Added some more mobile styles and tweaked the code around the CTA button.
/*Responsive screens*/
#media screen and (max-width: 500px) {
.stack-column, .stack-column-center { display: block !important;width: 100% !important;max-width: 100% !important;direction: ltr !important; padding-left:0px !important; padding-right:0px !important; padding-bottom:0px !important }
.stack-column-center { text-align: center !important; padding-left:0px !important; padding-right:0px !important; }
.center-on-narrow { text-align: center !important;display: block !important;margin-left: auto !important;margin-right: auto !important;float: none !important; }
table.center-on-narrow { display: inline-block !important; }
.email-container p { font-size: 17px !important; }
.middle-article-mobile-pt { padding-top: 60px !important; }
.middle-article-mobile-pb { padding-bottom: 60px !important; }
.text-right-mobile { padding: 0px !important; }
.body-copy, .body-copy-2, .body-h1, .body-h2, .light-blue-button, .orange-button, .mobile-center { text-align:center !important; }
}
<tr>
<td dir="ltr" height="100%" style="padding: 30px 50px; background-color: #ffffff;" valign="top" width="100%" ><!--[if mso]>
<table align="center" role="presentation" border="0" cellspacing="0" cellpadding="0" width="500" style="width: 500;">
<tr>
<td valign="top" width="500" style="width: 500;">
<![endif]-->
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="max-width:500px; padding:0; margin:0;" width="100%">
<tbody>
<tr style="padding:0;margin:0;">
<td align="center" style="font-size:0; padding: 0 0 60px 0;border-bottom:1px solid #ebebeb;" valign="top" class=""><!--[if mso]>
<table role="presentation" border="0" cellspacing="0" cellpadding="0" width="500" style="width: 500;">
<tr>
<td valign="top" width="200" style="width: 200px;">
<![endif]-->
<div class="stack-column" style="display:inline-block; margin: 0; max-width: 200px; vertical-align:top; width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody>
<tr>
<td dir="ltr" style="padding: 0 10px 0 10px;" class=""><img alt="alt_text" border="0" class="center-on-narrow" height="" src="http://go.pardot.com/l/190862/2019-04-09/h9rldk/190862/77786/template_testing_200px_placeholder.png" style="width: 100%; max-width: 200px; height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; line-height: 15px; color: #555555;" width="200"></td>
</tr>
</tbody>
</table>
</div>
<!--[if mso]>
</td>
<td valign="top" width="300" style="width: 300px;">
<![endif]-->
<div class="stack-column" style="display:inline-block; margin: 0; max-width:300px; vertical-align:top;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody>
<tr>
<td class="center-on-narrow text-right-mobile" dir="ltr" style="font-family: sans-serif; font-size: 15px; line-height: 20px; color: #555555; padding: 0 0 0 20px; text-align: left;">
<p class="body-h1" style="margin:0;">Headline</p>
<p class="body-h2" style="margin:0;"><a href="##" style="text-decoration:underline;">Author, CPA<br>
Title title title title</a></p>
<p class="body-copy" style="margin: 15px 0;">Maecenas sed ante pellentesque, posuere leo id, eleifend dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>
<!-- Button : BEGIN -->
<table border="0" cellpadding="0" cellspacing="0" >
<tbody>
<tr>
<td>
<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td bgcolor="#05090c7" pardot-data="" style="border-radius: 2px; background: rgb(255,255,255);" class=""><a class="light-blue-button" href="##"><!--[if mso]> <![endif]-->Read the Article <!--[if mso]> <![endif]--></a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!-- Button : END --></td>
</tr>
</tbody>
</table>
</div>
<!--[if mso]>
</td>
</tr>
</table>
<![endif]--></td>
</tr>
</tbody>
</table>
<!--[if mso]>
</td>
</tr>
</table>
<![endif]--></td>
</tr>
Iam tying to create an newsletter, but in outlook mobile it does not pick up the correct styling. The styling which is not picked up is as follow: bold text, color of text and uppercase
Here a link to the output
The titles like Folio .... needs to be blue and bold.
thereby the text in buttons needs to be white and bold.
And the text in de full width button has to be uppercased and white
here is the html of an element with the image left text right:
<!-- // Begin Module: [Dark] Image left text right \\ -->
<table class="responsive-table" width="650" bgcolor="#d1d6e1" border="0" cellpadding="0" cellspacing="0" align="top" mc:repeatable="trading" mc:variant="[Dark] Image left text right">
<tbody>
<tr>
<td width="5%"></td>
<td width="90%" align="center">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr><td width="650" height="30"></td></tr>
<tr>
<td width="35%" align="center" valign="top" class="mobile-width-100" mc:label="image" mc:edit="iltrdimage">
<a href="#" target="_blank">
<img src="http://placehold.it/800x538" width="230" style="text-decoration: none;">
</a>
</td>
<td width="5%" class="mobile-height-30"></td>
<td width="60%" align="left" valign="top">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding-bottom: 5px;" mc:label="body title" md:hideable="" mc:edit="iltrdbodytitle">
<a href="#" class="block-title" style="font-family: 'OpenSans', Arial; font-size: 16px !important;line-height: 18px;color: #224691; text-decoration: none; font-weight: 700;" mc:label="heading">
<font color="#224691">Title</font>
</a>
</td>
</tr>
<tr>
<td style="padding-bottom: 10px;" mc:label="body text" mc:edit="iltrdbodytext">
<span style="font-family: 'OpenSans', Arial; color: #323232;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pharetra hendrerit felis, eget auctor ex tincidunt eget. Vestibulum consequat quam nibh.
</span></td>
</tr>
</table>
<table bgcolor="#2f57ad" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td align="center" class="btn">
<table cellpadding="0" cellspacing="0">
<tr>
<td mc:label="button" mc:edit="iltrdbutton">
<font color="#ffffff">Read more</font>
</td>
<td style="padding-left: 10px; padding-top: 1px;"><span style="font-size: 13px; color: #fff;">▸</span></td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr><td width="650" height="30"></td></tr>
</tbody>
</table>
</td>
<td width="5%"></td>
</tr>
</tbody>
</table>
<!-- // End Module: [Dark] Image left text right \\ -->
outlook does not support all css please go have a look at https://www.campaignmonitor.com/css/
outlook versions just as ie have different css to consider so you would need something like this to cater for all the options
<!--[if gte mso 9]>
<style type="text/css">
/* Your Outlook-specific CSS goes here. */
</style>
<![endif]-->
I'm creating a eDM newsletter as a template in Marketo and it views fine in nearly everything but gmail. Divs with images seem to be creating a bottom-margin or something and I can't figure out how to get rid of it. Please see mark up below and an image with red rectangles representing the problem margin areas.
Thanks!
<html>
<head>
<title>Responsive Template</title>
</head>
<body style="margin: 0px; padding: 0px;">
<table cellpadding="0" cellspacing="0" valign="top" width="100%" align="center" bgcolor="#EBEBEB" style="padding: 0px; margin: 0px;">
<tr>
<td>
<table align="center" cellpadding="0" cellspacing="0" valign="bottom">
<tr>
<td width="20"> </td>
<td><div class="mktEditable" id="headerImage" style="margin: 0px; padding: 0px;"><img src="https://placeholdit.imgix.net/~text?txtsize=25&txt=610%C3%97100&w=610&h=100" alt=""/></div></td>
<td width="20"> </td>
</tr>
</table>
<table align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="650"><div class="mktEditable" id="topBanner" style="margin: 0px; padding: 0px;"><img src="http://www.vision6.com.au/download/files/20677/2408194/Header.png" alt=""/></div></td>
</tr>
</table>
<table align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="20"> </td>
<td width="610" bgcolor="#FFFFFF"><div class="mktEditable" id="mainContent" style="padding: 20px; margin: 0px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis pharetra mi ut finibus. Sed elementum eros ut augue egestas eleifend. Quisque nibh neque.</div></td>
<td width="20"> </td>
</tr>
</table>
<table align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="20"> </td>
<td width="610" bgcolor="#FFFFFF">
<div class="mktEditable" id="footerImage" style="margin: 0px; padding: 0px;">
<img style="margin: 0px; padding: 0px;" src="https://placeholdit.imgix.net/~text?txtsize=25&txt=610%C3%97100&w=610&h=100" alt=""/>
</div></td>
<td width="20"> </td>
</tr>
</table>
</td>
</tr>
</table>
</body>
<style>
#media only screen and (max-width: 650px) {
body {
width: 100% !important;
min-width: 100% !important;
}
img {
float: none !important;
height: auto;
max-width: 100%;
margin: 0px !important;
padding: 0px !important;
}
</style>
</html>
IMG(gmail): http://s4.postimg.org/p2cwbvdn1/gmailmarginissue.jpg
edit*
IMG(No margin issue/Outlook): http://s16.postimg.org/yikdy0md1/Screen_Shot_2015_09_07_at_2_39_30_pm.png
Gmail domain will not always support div tags, hence remove div tags and apply css to td and also make sure to give alignments to td's(ex: <td align="left" valign="top"></td>)
line-height was the issue. It was adding an extra 3px to the .
I'm using an email template with inline style. Unfortunately the button in this template is not linked, but only the word in the button.
My problem: I've linked the whole table, but then it didn't look correctly in Firefox (blue underline, some wrong pixels on left-hand side).
How can I link the whole button correctly?
<table border="0" align="center" width="260" cellpadding="0" cellspacing="0" bgcolor="2a99d8" style="border-radius: 5px;" class="main_color">
<tr><td height="13" style="font-size: 13px; line-height: 13px;"> </td></tr>
<tr>
<td>
<table border="0" align="center" cellpadding="0" cellspacing="0" style="border-radius: 5px; border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
<tr>
<td align="center" style="color: #ffffff; font-size: 14px; font-weight: 700; font-family:'Roboto', Arial, sans-serif;">
<!-- ======= main section button ======= -->
<div style="line-height: 24px;">
FIND OUT MORE
</div>
</td>
<td width="20" align="right">
<img align="bottom" width="6" height="10" style="width: 6px; height: 10px;" src="http://promailthemes.com/raula/img/btn-arrow.png" />
</td>
</tr>
</table>
</td>
</tr>
<tr><td height="13" style="font-size: 13px; line-height: 13px;"> </td></tr>
</table>
Put the table in a containing div and use javascript to link to hyperlink the div.