I have a two column structure. The left holds the left side of one image, and the right holds the right side of the same image. I do this so that a user can click on the left to be directed one place, and the right to be directed another place.
Here's what it looks like:
CSS
<style type="text/css">
body {width: 100%; background-color: #ffffff; margin:0; padding:0; -webkit-font-smoothing: antialiased;font-family: Georgia, Times, serif}
table {border-collapse: collapse;}
table.fixed { table-layout:fixed; }
table.fixed td { overflow: hidden; }
#media only screen and (max-width: 640px) {
body[yahoo] .deviceWidth {width:440px!important; padding:0;}
body[yahoo] .center {text-align: center!important;}
}
#media only screen and (max-width: 479px) {
body[yahoo] .deviceWidth {width:280px!important; padding:0;}
body[yahoo] .center {text-align: center!important;}
}
</style>
HTML
<table width="580" border="0" cellpadding="0" cellspacing="0" align="center" class="deviceWidth" bgcolor="#ffffff">
<tr>
<td class="center" style="padding:0px 0 0 0px">
<table width="50%" border="0" cellpadding="0" cellspacing="0" align="left" class="deviceWidth">
<tr>
<td style="padding: 0px 0px 12px 0px" align="center">
<p style="mso-table-lspace:0;mso-table-rspace:0; margin:0"><img width="290" src="blah" alt="" border="0" style="width: 290px" class="deviceWidth" /></td>
</td>
</tr>
</table>
<table width="50%" border="0" cellpadding="0" cellspacing="0" align="right" class="deviceWidth">
<tr>
<td style="padding: 0px 0px 12px 0px" align="center">
<p style="mso-table-lspace:0;mso-table-rspace:0; margin:0"><img width="290" src="blah2" alt="" border="0" style="width: 290px" class="deviceWidth" />
</td>
</tr>
</table>
</td>
</tr>
</table>
The issue is...I want to make it responsive. But instead of stacking one table on top of the other, I want them to shrink side-by-side so that the image is preserved. How can I achieve this?
EDIT:
Here's a fiddle:
http://jsfiddle.net/54c5W/
I'd like the images to remain side-by-side when I shrink the screen, not stack on top of each other.
Related
I am trying to scale a table cell that has a background image for an email I'm developing. However, I'm having trouble making the height dynamic on the mobile version.
The table cell:
Has no content over the background image
Stacks on mobile
Needs to show the image in a 1:1 ratio, with none of the image cut off at the top or the sides
Is full width on mobile
Fiddle
The fiddle will make the issue clear when you resize your browser window - The cell stacks fine and the width is fine, it's the height that's the problem. The height of the cell is too low, cutting off some of the image.
I need the height to firstly be exactly 385px x 256px on desktop (the exact size of the image), then 100% width on mobile, while also having a full image height on mobile.
There are reasons behind this approach which are not worth boring you with here.
The code:
HTML
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center">
<table width="215" height="256" border="0" cellspacing="0" cellpadding="0" style="float:left;" align="left" class="100p" bgcolor="#eeeeee">
<tr>
<td width="215" style="float:left;" align="left" class="displayproperlyplease 100nopad">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="256">
<tr>
<td align="center">
TEXT
</td>
</tr>
</table>
</td>
<td width="20"></td>
</tr>
</table>
<table width="385" border="0" cellspacing="0" cellpadding="0" class="100p" style="float:left;display:inline" align="right">
<tr>
<td width="20" ></td>
<td background="http://msgfocus.com/files/amf_to_infinity/workspace_83/2-years.jpg" style="background-position:left; background-size:cover; float:left;" bgcolor="#0c0807" width="385" class="100nopad" valign="right" align="middle">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="256">
<tr>
<td align="center">
</td>
</tr>
</table>
</td>
<td width="20"></td>
</tr>
</table>
</td>
</tr>
</table>
CSS
#media (max-width:630px) {
*[class="100p"] {width:100% !important; height:auto !important; text-align:center !important;}
*[class="100pad"] {width:95% !important;}
*[class="100nopad"] {width:100% !important; padding-right: 0 !important; padding-left: 0 !important; float: none !important; text-align: center;}
*[class="displayproperlyplease 100nopad"] {width:100% !important; padding-right: 0 !important; padding-left: 0 !important; float: none !important; text-align: center;}
table[class="wrapper"] {width: 100%;}
table[class="wrapper"] .fl {width: 100% !important;float: left;height: auto;}
}
How can I make the background image on mobile be 100% width, but have the height increase/reduce to ensure none of the image is cut off?
I have two side by side table cells which stack when triggered by a media query for a HTML newsletter. I want the headlines "Be Ready" and "Stay Organized" to left align when the responsive code fires but the "margin: 0px auto" causes all of the content to center. Is there a way to get these to stay left aligned? If I move them out of the table data cell from the rest of the content, everything messes up.
The "Stay Organized" and "Be Ready" headlines are centered when the code is responsive. I need them left aligned instead.
This is what it's supposed to look like on mobile: http://imgur.com/vT3XhJ6
Any help is appreciated.
<!DOCTYPE html>
<!--
-->
<html lang="en">
<head><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<style type="text/css">
table td {border-collapse:collapse;}
table[class=tblPreHeaderLinks] {
width: 100% !important;
height: 25px !important;
clear: both !important;
float: none !important;
}
.appleLinks2 a {
color:#333333 !important;
text-decoration: none !important;
}
/* CLIENT-SPECIFIC STYLES */
#outlook a{padding:0;} /* Force Outlook to provide a "view in browser" message */
.ReadMsgBody{width:100%;} .ExternalClass{width:100%;} /* Force Hotmail to display emails at full width */
.ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;} /* Force Hotmail to display normal line spacing */
body, table, td, a{-webkit-text-size-adjust:100%; -ms-text-size-adjust:100%;} /* Prevent WebKit and Windows mobile changing default text sizes */
table, td{mso-table-lspace:0pt; mso-table-rspace:0pt;} /* Remove spacing between tables in Outlook 2007 and up */
img{-ms-interpolation-mode:bicubic;} /* Allow smoother rendering of resized image in Internet Explorer */
/* RESET STYLES */
body{margin:0; padding:0;}
img{border:0; height:auto; line-height:100%; outline:none; text-decoration:none;}
table{border-collapse:collapse !important;}
body{height:100% !important; margin:0; padding:0; width:100% !important;}
/* iOS BLUE LINKS */
.appleBody a {color:#68440a; text-decoration: none;}
.appleFooter a {color:#999999; text-decoration: none;}
/* MOBILE STYLES */
#media screen and (max-width: 525px) {
body[yahoo] .block_td {display: block;}
.appleLinks2 a {
color:#545861 !important;
text-decoration: none !important;
}
body {
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
div[class="mobilecontent"]{
display: block !important;
max-height: none !important;
}
/* ALLOWS FOR FLUID TABLES */
table[class="wrapper"]{
width:100% !important;
}
/* USE THESE CLASSES TO HIDE CONTENT ON MOBILE */
td[class="mobile-hide"]{
display:none;}
img[class="mobile-hide"]{
display: none !important;
}
img[class="img-max"]{
max-width: 100% !important;
width: 100% !important;
height:auto !important;
}
a.learnMore {
display: block;
text-align: center;
}
/* UTILITY CLASSES FOR ADJUSTING PADDING ON MOBILE */
td[class="section-padding"]{
padding: 10px 15px 5px 15px !important;
}
/* FULL-WIDTH TABLES */
table[class="responsive-table"]{
width:100%!important;
}
td[class="weatherTEXT"]{
font-size: 23px !important;
line-height: 27px !important;
}
td[class="weatherTEXT2"]{
font-size: 17px !important;
line-height: 21px !important;
}
}
</style>
</head>
<body yahoo="fix" style="margin: 0; padding: 0;" bgcolor="#f6f4f5">
<style type="text/css">
body { width: 100% !important; }
</style>
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="wrapper" style="border:1px solid #e2e0e0;">
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0" width="640" class="wrapper" bgcolor="#f6f4f5">
<tr>
<td align="center">
<!--BODY-->
<table border="0" cellpadding="0" cellspacing="0" width="640" class="wrapper" bgcolor="#f6f4f5" align="center">
<tbody><tr>
<td width="640" align="center" bgcolor="#ffffff" class="section-padding" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td bgcolor="#ffffff" align="center" style="padding: 5px 0px 5px 0px;" class="section-padding">
<table border="0" cellpadding="0" cellspacing="0" width="640" class="responsive-table" align="center">
<tbody>
<tr><!--MOVABLE INK-->
<td>
<table border="0" cellpadding="0" cellspacing="0" width="640" class="wrapper" bgcolor="#ffffff" align="center">
<tbody><tr>
<td style="padding: 15px 15px 5px 15px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="290" class="block_td" style="margin:0px auto;">
<table cellpadding="0" cellspacing="0" border="0" >
<tr>
<td align="left" style="font-family: Ariel, Arial, Helvetica, sans-serif; font-size: 22px; line-height: 26px; color:#002663;padding:0px 0px 25px 0px;" colspan="2">
<b>Be Ready.</b>
</td>
</tr>
<td rowspan="3" valign="top" width="57" style="padding-right:10px;;">
<img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/CatAuto-Phone-35x73.jpg" width="35" height="73" alt="House getting hit by a fallen tree" border="0">
</td>
<td valign="top" align="left">
<table cellpadding="0" cellspacing="0" border="0" style="padding: -5px 0px 0px 0px;">
<tr>
<td style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#333333; line-height:17px; padding-left:0px;">
<b>Download our app:</b>
</td>
</tr>
<tr>
<td valign="top" style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;">
<table cellpadding="2" cellspacing="2" border="0">
<tr>
<td style="valign="top">•</td>
<td style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;">Take pictures of damage</td>
</tr>
<tr>
<td valign="top">•</td>
<td style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;">Submit your claim</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style=" padding-top:2px;padding-bottom:35px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td class="mobile-hide">
<img src="http://www.movable-ink-7850.com/p/rp/aa8600496aa4ae32.png?MM_webID=%%WebID%%" alt="House getting hit by a fallen tree">
</td>
</tr>
<tr>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td style="padding-right:35px;">
<!--[if !mso 9]><!-->
<div class="mobilecontent" style="mso-hide:all;display:none;max-height:0px;overflow:hidden;" align="center">
<img src="http://www.movable-ink-7850.com/p/rp/aa8600496aa4ae32.png?MM_webID=%%WebID%%" border="0" alt="House getting hit by a fallen tree">
</div>
<!--<![endif]-->
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td valign="top" width="290" class="block_td" style="margin:auto;">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="font-family: Ariel, Arial, Helvetica, sans-serif; font-size: 22px; line-height: 26px; color:#002663;padding:0px 0px 25px 0px;" colspan="2">
<b>Stay Organized.</b>
</td>
</tr>
<tr>
<td rowspan="3" valign="top" width="60" style="padding-right:10px;">
<img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/CatAuto-Icon-Devices-50x50.jpg" alt="" border="0">
</td>
<td valign="top" align="left">
<table cellpadding="0" cellspacing="0" border="0" style="padding: -5px 0px 0px 0px;">
<tr>
<td style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#333333; line-height:17px; padding-left:0px;">
<b>Visit eService today:</b>
</td>
</tr>
<tr>
<td valign="top" style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;">
<table cellpadding="2" cellspacing="2" border="0">
<tr>
<td valign="top">•</td>
<td style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;"><span class="appleLinks2">24/7 access</span></td>
</tr>
<tr>
<td valign="top">•</td>
<td style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;">Manage your policy online</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="padding-top:2px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td class="mobile-hide">
<img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/CatAuto-Button-Sign-In-70x19.jpg">
</td>
</tr>
<tr>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td style="padding-top: 30px; padding-right:40px;">
<!--[if !mso 9]><!-->
<div class="mobilecontent" style="mso-hide:all;display:none;max-height:0px;overflow:hidden;" align="center">
<a href="https://www.libertymutual.com/home-insurance/home-coverages-and-benefits/home-insurance-benefits/property-replacement-service?MM_webID=%%WebID%%"><img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/CatAuto-Button-Sign-In-139x38.jpg" width="139" height="38" border="0" alt="House getting hit by a fallen tree">
</div>
<!--<![endif]-->
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td style="padding: 15px 15px 20px 15px;" class="tdLine">
<table width="100%" align="center" cellpadding="0" cellspacing="0" class="tblLine">
<tr>
<td style="line-height:1px; font-size:1px; background-color:#f6f4f5" class="tdLineActual"> </td>
</tr>
</table> <!-- tblLine -->
</td> <!-- tdLine -->
</tr>
</tbody></table>
</td>
</tr><!--END OF MOVABLE INK-->
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table><!--END OF BODY-->
</td>
</tr>
</table>
</td>
</tr>
</table><!--END OF CONTAINER-->
</body>
</html>
However i dont recommend to use nested tables but for your structure added one more table for desired results: demo
<table width="80%" border="0" align="center" cellspacing="0" cellpadding="0">
My responsive email is aligning to the left in iphone 6. I have align="center" on the containing tables and TD's. 320px width is specified in media queries with the main containing table having a width="100%".
#media only screen and (max-device-width: 480px)
table[class=threeHundred20], td[class=threeHundred20], tr[class=threeHundred20] {
width: 320px !important;
display: block !important;
}
I know that iphone 6 is higher than my specified 320 width which has created side gutters of space which I don't mind, but I need to center the main content. Is there any way to do this without changing my media queries to target different sizes? I want to avoid going down this route.
Display:block can sometimes force a left align of content if the content is smaller then the parent container. Try instead using inline-block for display with text-align: center.
due to some past experiences with
align:center;
I would recommend you use
margin-left: 50%;
margin-right: 50%;
instead.
I have always used this way, and it works on all devices and email clients
demo: https://jsfiddle.net/cL011mw3/
html:
<table width="100%">
<tr>
<td>
<table width="640" class="width320" align="center">
<tr>
<td bgcolor="#999999">
text
</td>
</tr>
</table>
</td>
</tr>
Css:
#media only screen and (max-width: 500px){
*[class].width320{
width:320px !important
}
}
This work perfectly for me :
Add metas :
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<meta name="x-apple-disable-message-reformatting" />
Add media querie
#media only screen and (max-width: 480px){
.fullwidth,
.fullwidth tbody,
.fullwidth tbody > tr,
.fullwidth tbody > tr > td,
.fullwidth tbody > tr > th,
table[class=fullwidth],
table[class=fullwidth] tbody,
table[class=fullwidth] tbody > tr,
table[class=fullwidth] tbody > tr > td,
table[class=fullwidth] tbody > tr > th
td[class=main-border] {
max-width: 100% !important;
min-width: 100% !important;
width: 100% !important;
display: block !important; <!-- table, tbody, tr, td became blocs -->
clear: both; <!-- to prevent floating ex: <table align="left"…> -->
margin: 0 auto !important; <!-- to center the blocs -->
}
}
Don't forget tbody in you table an outlook styles to extra white space :
Table wrapper + main container table :
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;margin: 0;padding: 0;margin:0 auto;">
<tbody>
<tr>
<td valign="middle" align="center">
<table class="fullwidth" width="600" cellspacing="0" cellpadding="0" border="0" align="center" style="borde-r-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;margin: 0;padding: 0;margin:0 auto;">
<tbody>
<tr>
<td style="font-size:5px;line-height:5px; height: 10px"> </td> <!-- paddign & margin not supported by Outlook -->
</tr>
<tr>
<td valign="middle" align="center">
<table class="fullwidth" width="100%" cellspacing="0" cellpadding="0" border="0" align="center" style="borde-r-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;margin: 0;padding: 0;margin:0 auto;">
<tbody>
<tr>
<td>Col 1</td>
<td>Col 2</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td style="font-size:5px;line-height:5px; height: 10px"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
I'm coding a responsive email, and I'm running onto some troubles with the behavior of some its tables. Please check the attached picture, for the desired effect.
https://dl.dropboxusercontent.com/u/58655025/mail_scenario.jpg
(left: "normal" behavior; right: responsive behavior, when the view width is <= 320px)
I'm not exactly sure of how many elements these blocks (both rectangular and the square ones; number of block elements and contents are dynamic) will have in total, so I want to keep the HTML as dynamic as possible. So, every time a new element is added to each block, it's placed at the right of the previous one and when they cannot fit on that line (due to email's max-width of 620px), I'd like for them to continue below.
And that's the part I'm not able to do. Instead of breaking below, the elements keep growing in the same line, ignoring the email's max-width property.
I'd like for the implementation to be table-based only, in order to guarantee the maximum email-client support as possible.
What can I do to achieve this? Any other suggestion?
Please, check this fiddle for a live example: http://jsfiddle.net/afe33fhv/
Or the HTML code, as required:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Title</title>
<style type="text/css">
/* Client-specific Styles */
#outlook a {padding:0;}
body {width:100% !important; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; margin:0; padding:0; color:#756d85; font-family:Helvetica, Arial, sans-serif;}
body.outlook img { width: auto !important; max-width: none !important;}
.ExternalClass {width:100%;}
.ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height:100%;}
.backgroundTable {margin:0; padding:0; width:100% !important; line-height:100% !important;}
img {outline:none; text-decoration:none; border:none; -ms-interpolation-mode:bicubic;}
a img {border:none;}
.image_fix {display:block;}
p {margin: 0px 0px !important;}
table td {border-collapse: collapse;}
table { border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; }
a {color: #756d85;text-decoration: none;text-decoration:none!important;}
table[class=full] { width: 100%; clear:both; }
/*IPAD STYLES*/
#media only screen and (max-width: 640px) {
a[href^="tel"], a[href^="sms"] {
text-decoration: none;
color: #000;
pointer-events: none;
cursor: default;
}
table[class=devicewidth] {width:440px !important; text-align:center !important;}
table[class=devicewidthinner] {width:420px !important; text-align:center !important;}
table[class=devicewidthsocial] {width:200px! important; text-align:center !important;}
img[class=banner] {width:440px !important; height:220px !important;}
img[class=colimg2] {width:440px !important; height:220px !important;}
}
/*IPHONE STYLES*/
#media only screen and (max-width: 480px) {
a[href^="tel"], a[href^="sms"] {
text-decoration: none;
color: #000;
pointer-events: none;
cursor: default;
}
table[class=devicewidth] {width:300px !important; text-align:center !important;}
table[class=devicewidthinner] {width:260px !important; text-align:center !important;}
table[class=devicewidthsocial] {width: 200px!important; text-align:center !important;}
img[class=banner] {width: 280px!important; height:140px!important;}
img[class=colimg2] {width: 280px!important; height:140px!important;}
td[class=mobile-hide]{display:none !important;}
}
</style>
</head>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">
<center>
<!-- | Horizontal blocks | -->
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="backgroundTable">
<tbody>
<tr>
<td>
<table width="620" cellpadding="0" cellspacing="0" border="0" align="center" class="devicewidth" bgcolor="#f2f2f2">
<tbody>
<tr>
<!-- Element 1 -->
<td>
<table width="300" height="100" cellpadding="0" cellspacing="0" border="0" align="center">
<tbody>
<tr>
<td>
<table width="300" height="80" cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="#7c84ca">
<tbody>
<tr><td width="100%">1</td></tr>
</tbody>
</table>
</td>
</tr>
<tr><td width="100%" height="10" style="font-size:1px; line-height:1px; mso-line-height-rule:exactly;"> </td></tr>
</tbody>
</table>
</td>
<!-- Element 2 -->
<td>
<table width="300" height="100" cellpadding="0" cellspacing="0" border="0" align="center">
<tbody>
<tr>
<td>
<table width="300" height="80" cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="#bdaabf">
<tbody>
<tr><td width="100%">2</td></tr>
</tbody>
</table>
</td>
</tr>
<tr><td width="100%" height="10" style="font-size:1px; line-height:1px; mso-line-height-rule:exactly;"> </td></tr>
</tbody>
</table>
</td>
<!-- Element 3 -->
<td>
<table width="300" height="100" cellpadding="0" cellspacing="0" border="0" align="center">
<tbody>
<tr>
<td>
<table width="300" height="80" cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="#d26ec1">
<tbody>
<tr><td width="100%">3</td></tr>
</tbody>
</table>
</td>
</tr>
<tr><td width="100%" height="10" style="font-size:1px; line-height:1px; mso-line-height-rule:exactly;"> </td></tr>
</tbody>
</table>
</td>
<!-- Element 4 -->
<td>
<table width="300" height="100" cellpadding="0" cellspacing="0" border="0" align="center">
<tbody>
<tr>
<td>
<table width="300" height="80" cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="#d85c79">
<tbody>
<tr><td width="100%">4</td></tr>
</tbody>
</table>
</td>
</tr>
<tr><td width="100%" height="10" style="font-size:1px; line-height:1px; mso-line-height-rule:exactly;"> </td></tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!-- | Square blocks | -->
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="backgroundTable">
<tbody>
<tr>
<td>
<table width="620" cellpadding="0" cellspacing="0" border="0" align="center" class="devicewidth" bgcolor="#f2f2f2">
<tbody>
<tr>
<!-- Element 1 -->
<td>
<table width="140" height="140" cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="#8eb7c2">
<tbody>
<tr><td>1</td></tr>
</tbody>
</table>
</td>
<!-- Element 2 -->
<td>
<table width="140" height="140" cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="#8ec296">
<tbody>
<tr><td>2</td></tr>
</tbody>
</table>
</td>
<!-- Element 3 -->
<td>
<table width="140" height="140" cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="#636a34">
<tbody>
<tr><td>3</td></tr>
</tbody>
</table>
</td>
<!-- Element 4 -->
<td>
<table width="140" height="140" cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="#c17b01">
<tbody>
<tr><td>4</td></tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</center>
</body>
</html>
You probably want to scrap the tables. Set all the blocks to display: inline-block; and they will automatically wrap around to the next line if the parent container hasn't got enough width left.
By using media queries, you can make sure the boxes parent container can only take on certain widths, creating your desired effect.
Here is a jsfiddle demonstrating: http://jsfiddle.net/spkzj05b/2/
Here is a list of css features supported in popular email clients: https://www.campaignmonitor.com/css/
Here is a tool to test the rendering in different email clients: https://litmus.com/email-testing
I am doing a responsive email where I can move the images if the email is being viewed on mobile.Everything looks great except in Outlook. It is displaying it in both places. I read that outlook does not recognize the "display:none" code. Is there anything else that can be done?
Here is what I have my code looking like and its working on everything but outlook.
Media Query Code
#media only screen and (max-device-width: 479px) {
#mobile {display:block}
#desktop {display:none;mso-hide: all;}
}
#media only screen and (min-device-width: 480px) {
#mobile {display:none;mso-hide: all;}
#desktop {display:block}
}
}
And here is the html I am using.
<table id="mobile" align="right" width="35%" cellpadding="0" cellspacing="0" border="0" class="deviceWidth">
<tr>
<td valign="top" align="right" class="hisrc">
<p style="mso-table-lspace:0;mso-table-rspace:0; margin:0; font-family:Helvetica, sans-serif; font-size:11px; color:323338; text-align:left; line-height:15px;">
<img src="vna-logo.png" alt="" border="0" style="padding-bottom:18px;border-radius: 4px; width: 220px;" class="deviceWidth" />
</td>
</tr>
</table>
<table id="desktop" align="right" width="35%" cellpadding="0" cellspacing="0" border="0" class="deviceWidth">
<tr>
<td valign="top" align="right" class="hisrc">
<p style="mso-table-lspace:0;mso-table-rspace:0; margin:0; font-family:Helvetica, sans-serif; font-size:11px; color:323338; text-align:left; line-height:15px;">
<img src="vna-logo-2.png" alt="" border="0" style="padding-bottom:18px;border-radius: 4px; width: 220px;" class="deviceWidth" />
</td>
</tr>
</table>
<table id="mobile" align="right" width="35%" cellpadding="0" cellspacing="0" border="0" class="deviceWidth" style="display:none;">
Should hide mobile version by default, will stay hidden on clients where queries are not accepted