I’m having trouble displaying a background image in a table within my Django app. Here’s the code I’m using:
<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>
However, when I try to apply the same CSS styling to a div element, it works fine:
<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>
I can’t figure out why the background image isn’t showing up in the table. Any help would be greatly appreciated.
EDIT1
I’m trying to include an email HTML file in a Django template using ‘include’. The image displays correctly, but the background-image style doesn’t work – unless I use a ‘div’ instead of a ‘table’. Could this be related to Bootstrap?
EDIT2
Here is the complete code snippet. Despite setting the background image in the table, it doesn’t appear:
<!-- ======= 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">
<a href="" style=" border-style: none !important; border: 0 !important;"><img src="http://themastermail.com/envato/omail/demo/layout2/img/testi-img.png" style="display: block; width: auto;" width="70" border="0" alt=""/></a>
</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><a href="" style="color: #f29a27; text-decoration: none;">envato.com</a>
</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 ====== -->