Skip to content Skip to sidebar Skip to footer

Responsive E-mail: Turn Table Cells (td) To (cleared) Blocks

I have this basic example that should display these three table cells as blocks (underneath each other) on mobile devices. Yet this doesn't seem to work out on iPad, iPhone, nor on

Solution 1:

Use three nested tables with "align=" to replicate "float" and have a media query to resize table to 100% with display:block on mobile.

I added classes to differentiate between container and block tables. Also added a couple inline styles to help.

E.G.

<!DOCTYPE htmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><metacharset="utf-8"><title>Mobilize me</title><styletype="text/css">@mediaonly screen and (max-width: 900px) {
            .container {
                width: 100%!important;
                text-align:center !important;
            }
            .blocktable {
                width: 100%!important;
                display: block !important;
                margin: 0 auto !important;
            }
        }
    </style></head><body><tablecellspacing="0"cellpadding="0"border="0"width="900"class="container"style="border-collapse:collapse;"><tr><tdalign="center"><tablealign="left"bgcolor="RED"cellspacing="0"cellpadding="0"border="0"width="33%"class="blocktable"style="border-collapse:collapse;"><tr><td>one</td></tr></table><tablealign="left"bgcolor="GREEN"cellspacing="0"cellpadding="0"border="0"width="34%"class="blocktable"style="border-collapse:collapse;"><tr><td>two</td></tr></table><tablealign="right"bgcolor="BLUE"cellspacing="0"cellpadding="0"border="0"width="33%"class="blocktable"style="border-collapse:collapse;"><tr><td>three</td></tr></table></td></tr></table></body></html>

Solution 2:

I think it's safe to conclude, at the moment of this writing, that this technique is, or has become, unsupported.

A better approach would to work with 2 different displays: one design for desktop readers, and one for mobile readers, as demonstrated below (tested, and works):

<!DOCTYPE htmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=utf-8" /><styletype="text/css">
        <!--
        .ReadMsgBody {
            width: 100%;
        }
        .ExternalClass {
            width: 100%;
        }

        a:hover,
        a:visited,
        a:active {
            color: #ffffff;
        }

        @media screen and (max-width: 480px), screen and (max-device-width: 480px) {
            body { -webkit-text-size-adjust: none;}
            div[id=desktop] {
                display:none !important;
                width:0px!important;
                overflow:hidden !important;
            }
            div[id=mobile] {
                display:block !important;
                width:100%!important;
                height:auto !important;
                max-height:inherit !important;
                overflow:visible !important;
            }

            div[id=mobile]table{
                display: block !important;
                overflow: auto;
            }

            div[id=mobile]img{
                width: 100%;
            }
        -->
    </style><styletype="text/css">div.onlinep {margin:0; padding:0; margin-bottom:0;}
        div.onlinea:link, div.onlinea:visited, div.onlinea:hover, div.onlinea:active { color: #333333; }
    </style></head><bodybgcolor="#e6e6e6"style="margin:0;"><divclass="online"style="margin:10px auto; color: #333333; font-family: verdana; font-size:11px;text-align:center;"><ahref="http://somedomain.com/some/page.htm?lang=nl"target="_blank"style="text-decoration: none; color: #333333;">View in browser</a></div><divid="desktop"><tablecellpadding="10"cellspacing="0"border="0"style="width:100%; background-color:#e6e6e6;"><tr><tdalign="center"><tablecellpadding="0"cellspacing="0"border="0"style="width:620px; background-color:#ffffff; text-align:left;"><tr><td><tablecellpadding="0"cellspacing="20"border="0"style="width:620px; text-align:left; background-color:#ffffff;"><tr><td><ahref="#"target="_blank"><imgsrc="https://www.domain.com/x-http://somedomain.com/some/page/img/props/header.jpg"border="0"style="display:block;" /></a></td></tr></table></td></tr><tr><td><tablecellpadding="0"cellspacing="20"border="0"><tr><tdvalign="top"><imgsrc="https://www.domain.com/x-http://somedomain.com/some/page/img/props/00f_1.gif"style="max-width: 240px;" /></td><tdvalign="top"><tablecellpadding="0"cellspacing="0"border="0"style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333333;"><tr><tdstyle="font-size:22px; color:#fea900;">Block 1</td></tr><tr><td><imgsrc="https://www.domain.com/x-http://somedomain.com/some/page/img/props/filler12.png" /></td></tr><tr><td>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</td></tr></table></td></tr></table></td></tr><tr><td><tablecellpadding="0"cellspacing="20"border="0"><tr><tdvalign="top"><imgsrc="https://www.domain.com/x-http://somedomain.com/some/page/img/props/0f0_1.gif"style="max-width: 240px;" /></td><tdvalign="top"><tablecellpadding="0"cellspacing="0"border="0"style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333333;"><tr><tdstyle="font-size:22px; color:#fea900;">Block 2</td></tr><tr><td><imgsrc="https://www.domain.com/x-http://somedomain.com/some/page/img/props/filler12.png" /></td></tr><tr><td>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</td></tr></table></td></tr></table></td></tr><tr><tdalign="center"style="border-bottom: 2px dotted #666666;"><imgsrc="https://www.domain.com/x-http://somedomain.com/some/page/img/props/filler12.png" /></td></tr></table></td></tr></table></div><divid="mobile"style="display:none; width:0px; max-height:0px; overflow:hidden;"><tablecellpadding="10"cellspacing="0"border="0"style="width:100%; background-color:#e6e6e6; display:none;"><tr><tdalign="center"><tablecellpadding="0"cellspacing="0"border="0"style="width:100%; background-color:#ffffff; text-align:left; display:none;"><tr><td><tablecellpadding="0"cellspacing="0"border="0"style="width:100%; text-align:left; background-color:#ffffff; display:none;"><tr><td><ahref="#"target="_blank"><imgid="header"src="https://www.domain.com/x-http://somedomain.com/some/page/img/props/header.jpg"border="0"style="display:block;" /></a></td></tr></table></td></tr><tr><td><tablecellpadding="0"cellspacing="10"border="0"style="display:none;"><tr><td><tablecellpadding="0"cellspacing="10"border="0"style="font-family:Arial; font-size:14px; color:#333333; display:none;"><tr><td><imgsrc="https://www.domain.com/x-http://somedomain.com/some/page/img/props/00f_1.gif" /></td></tr><tr><tdstyle="font-size:20px; color:#fea900;">Block 1</td></tr><tr><td>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</td></tr></table></td></tr></table></td></tr><tr><td><tablecellpadding="0"cellspacing="10"border="0"style="display:none;"><tr><td><tablecellpadding="0"cellspacing="10"border="0"style="font-family:Arial; font-size:14px; color:#333333; display:none;"><tr><td><imgsrc="https://www.domain.com/x-http://somedomain.com/some/page/img/props/0f0_1.gif" /></td></tr><tr><tdstyle="font-size:20px; color:#fea900;">Block 2</td></tr><tr><td>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</td></tr></table></td></tr></table></td></tr><tr><tdalign="center"style="border-bottom: 2px dotted #666666;">&nbsp;</td></tr></table></td></tr></table></div><divclass="online"style="margin: 10px auto 25px; color: #333333; font-family: verdana; font-size:11px;text-align:center;"><palign="center"><ahref="http://somedomain.com/some/page.htm?lang=nl"target="_blank"style="text-decoration: none; color: #333333;">Unsubscribe</a> -
            <ahref="http://somedomain.com/some/page.htm?lang=nl"target="_blank"style="text-decoration: none; color: #333333;">Edit profile</a></p><palign="center"style="margin-top: 15px;"></p></div></body></html>

Post a Comment for "Responsive E-mail: Turn Table Cells (td) To (cleared) Blocks"