UNPKG

cerberus-email

Version:

A few simple, but solid patterns for responsive HTML email templates and newsletters. Even in Outlook and Gmail.

406 lines (367 loc) 18.2 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <!-- utf-8 works for most cases --> <meta name="viewport" content="width=device-width"> <!-- Forcing initial-scale shouldn't be necessary --> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Use the latest (edge) version of IE rendering engine --> <title></title> <!-- the <title> tag shows on email notifications on Android 4.4. --> <style type="text/css"> /* ensure that clients don't add any padding or spaces around the email design and allow us to style emails for the entire width of the preview pane */ body, #bodyTable { height:100% !important; width:100% !important; margin:0; padding:0; } /* Ensures Webkit- and Windows-based clients don't automatically resize the email text. */ body, table, td, p, a, li, blockquote { -ms-text-size-adjust:100%; -webkit-text-size-adjust:100%; } /* Forces Yahoo! to display emails at full width */ .thread-item.expanded .thread-body .body, .msg-body { width: 100% !important; display: block !important; } /* Forces Hotmail to display emails at full width */ .ReadMsgBody, .ExternalClass { width: 100%; background-color: #f4f4f4; } /* Forces Hotmail to display normal line spacing. */ .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height:100%; } /* Resolves webkit padding issue. */ table { border-spacing:0; } /* Resolves the Outlook 2007, 2010, and Gmail td padding issue, and removes spacing around tables that Outlook adds. */ table, td { border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; } /* Corrects the way Internet Explorer renders resized images in emails. */ img { -ms-interpolation-mode: bicubic; } /* Ensures images don't have borders or text-decorations applied to them by default. */ img, a img { border:0; outline:none; text-decoration:none; } /* Styles Yahoo's auto-sensing link color and border */ .yshortcuts a { border-bottom: none !important; } /* Styles the tel URL scheme */ a[href^=tel], .mobile_link, .mobile_link a { color:#222222 !important; text-decoration: underline !important; } /* Media queries for when the viewport is smaller than the default email width but not too narrow. */ @media screen and (max-device-width: 600px), screen and (max-width: 600px) { /* Constrains email width for small screens */ table[class="email-container"] { width: 100% !important; } /* Constrains tables for small screens */ table[class="fluid"] { width: 100% !important; } /* Forces images to resize to full width of their container */ img[class="fluid"], img[class="force-col-center"] { width: 100% !important; max-width: 100% !important; height: auto !important; } /* And centers these ones */ img[class="force-col-center"] { margin: auto !important; } /* Forces table cells into rows */ td[class="force-col"], td[class="force-col-center"] { display: block !important; width: 100% !important; clear: both; } /* And centers these ones */ td[class="force-col-center"] { text-align: center !important; } /* Forces table cells into rows */ /* Floats a previously stacked image to the left */ img[class="col-3-img-l"] { float: left; margin: 0 15px 15px 0; } /* Floats a previously stacked image to the right */ img[class="col-3-img-r"] { float: right; margin: 0 0 15px 15px; } /* Makes buttons full width */ table[class="button"] { width: 100% !important; } } /* Media queries for when the viewport is narrow. */ /* Rules prefixed with 'hh-' (for 'handheld') repeat much of what's above, but these don't trigger until the smaller screen width. */ @media screen and (max-device-width: 425px), screen and (max-width: 425px) { /* Helper only visible on handhelds. All styles are inline along with a `display:none`, which this class overrides */ div[class="hh-visible"] { display: block !important; } /* Center stuff */ div[class="hh-center"] { text-align: center; width: 100% !important; } /* Constrain tables for small screens */ table[class="hh-fluid"] { width: 100% !important; } /* Force images to resize to full width of their container */ img[class="hh-fluid"], img[class="hh-force-col-center"] { width: 100% !important; max-width: 100% !important; height: auto !important; } /* And center these ones */ img[class="hh-force-col-center"] { margin: auto !important; } /* Force table cells into rows */ td[class="hh-force-col"], td[class="hh-force-col-center"] { display: block !important; width: 100% !important; clear: both; } /* And center these ones */ td[class="hh-force-col-center"] { text-align: center !important; } /* Stack the previously floated images */ img[class="col-3-img-l"], img[class="col-3-img-r"] { float: none !important; margin: 15px auto !important; text-align: center !important; } } </style> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#f4f4f4" style="margin:0; padding:0; -webkit-text-size-adjust:none; -ms-text-size-adjust:none;"> <table cellpadding="0" cellspacing="0" border="0" height="100%" width="100%" bgcolor="#f4f4f4" id="bodyTable" style="border-collapse: collapse;table-layout: fixed;margin:0 auto;"><tr><td> <!-- Hidden Preheader Text : BEGIN --> <div style="display:none; visibility:hidden; opacity:0; color:transparent; height:0; width:0;line-height:0; overflow:hidden;mso-hide: all;"> Visually hidden preheader text. </div> <!-- Hidden Preheader Text : END --> <!-- Logo Left, Nav Right, 100% Nav Bar : BEGIN --> <table border="0" width="100%" cellpadding="0" cellspacing="0" align="center" bgcolor="#555555" style="text-align: center;"> <tr> <td> <table border="0" width="600" cellpadding="0" cellspacing="0" align="center" style="margin: auto;" class="email-container"> <tr> <td height="10" style="font-size: 0; line-height: 0;">&nbsp;</td> </tr> <tr> <td class="hh-force-col-center" valign="middle" style="text-align: left;"> <img src="http://placehold.it/200x40/888888/555555" alt="alt text" height="40" width="200" border="0"> </td> <td class="hh-force-col-center" valign="middle" style="padding: 10px 0;text-align: right;"> <a href="" style="color: #ffffff;font-family: sans-serif;">Link 1</a>&nbsp;&nbsp; <a href="" style="color: #ffffff;font-family: sans-serif;">Link 2</a>&nbsp;&nbsp; <a href="" style="color: #ffffff;font-family: sans-serif;">Link 3</a> </td> </tr> <tr> <td height="10" style="font-size: 0; line-height: 0;">&nbsp;</td> </tr> </table> </td> </tr> </table> <!-- Logo Left, Nav Right, 100% Nav Bar : END --> <!-- Logo Left Nav Right + Vertical Padding : BEGIN --> <table border="0" width="600" cellpadding="0" cellspacing="0" align="center" class="email-container" style="margin: auto;"> <tr> <td height="30" style="font-size: 0; line-height: 0;">&nbsp;</td> </tr> <tr> <td class="force-col-center" valign="middle" style="padding: 20px 0;text-align: left;"> <img src="http://placehold.it/300x75/888888/7777777" alt="alt text" height="75" width="300" border="0"> </td> <td class="force-col-center" valign="middle" style="padding: 20px 0;text-align: right;"> <a href="#" style="font-family: sans-serif;color: #444444;">Link 1</a>&nbsp;&nbsp; <a href="#" style="font-family: sans-serif;color: #444444;">Link 2</a>&nbsp;&nbsp; <a href="#" style="font-family: sans-serif;color: #444444;">Link 3</a> </td> </tr> <tr> <td height="30" style="font-size: 0; line-height: 0;">&nbsp;</td> </tr> </table> <!-- Logo Left Nav Right + Vertical Padding : END --> <!-- Email Container : BEGIN --> <!-- This table wraps the whole body email within it's width (600px), sets the background color (white) and border (thin, gray, solid) --> <table border="0" width="600" cellpadding="0" cellspacing="0" align="center" bgcolor="#ffffff" style="border: 1px solid #e5e5e5;margin: auto;" class="email-container"> <!-- Single Fluid Image, No Crop : BEGIN --> <tr> <td> <img src="http://placehold.it/600x350/888888/7777777" alt="alt text" height="350" width="600" border="0" style="display: block;" class="fluid"> </td> </tr> <!-- Single Fluid Image, No Crop : END --> <!-- Full Width, Fluid Column : BEGIN --> <tr> <td style="border-bottom: 1px solid #e5e5e5;"> <table border="0" width="100%" cellpadding="0" cellspacing="0" align="center"> <tr> <td style="padding: 30px; font-family: sans-serif; font-size: 16px; line-height: 22px; color: #444444;"> Ulla nec est tristique, tempor lacus eu, aliquam erat. Cras tristique, arcu ac tristique hendrerit, urna diam mollis libero, vitae gravida nisi lectus in leo. Aenean eu ligula id nisi euismod dapibus et eu mauris. Donec quis dictum velit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. <br><br> Donec nulla ante, cursus sit amet egestas ut, facilisis ut neque. Nullam sed est lorem. Aenean pharetra metus nisl, eu lacinia ante cursus quis. Integer facilisis elementum mi, sed auctor leo posuere sed. Nulla facilisi. </td> </tr> </table> </td> </tr> <!-- Full Width, Fluid Column : END --> <!-- Two Columns, With Padding ==> Stacked Layout : BEGIN --> <tr> <td style="border-bottom: 1px solid #e5e5e5;padding: 0 30px;"> <table border="0" width="100%" cellpadding="0" cellspacing="0" align="center" class="fluid"> <tr> <td height="30" style="font-size: 0; line-height: 0;" class="empty-spacer">&nbsp;</td> </tr> <tr> <td valign="top" style="padding-right: 30px;" class="hh-force-col-center"> <img src="http://placehold.it/200/888888/7777777" alt="alt text" height="200" width="200" border="0" style="display: block;margin: auto;" class="hh-force-col-center"> </td> <td valign="top" class="hh-force-col" width="100%" style="padding-left: 0;"> <table cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td style="width:100%; font-family: sans-serif; font-size: 16px; line-height: 22px; color: #444444; text-align: left;"> <div style="font-size: 0; line-height: 0; display: none; height: 30px;" class="hh-visible"></div> <div style="font-size: 22px;line-height: 1;" class="hh-center">Two Columns, Padded</div><br> Two columns, each with padding on all sides. Columns stack on narrow screens, maintaining said padding.<br><br> <table cellspacing="0" cellpadding="0" border="0" class="button" style="margin: 0;"> <tr> <td style="-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; background-image: url(http://tedgoas.github.io/Cerberus/assets/bg-btn.png); background-position: top left; background-repeat: repeat-x; background-color: #444444; text-align: center;"> <a href="http://www.google.com" style="color: #ffffff; font-family: sans-serif; font-size: 15px; line-height: 15px; text-align: center; text-decoration: none; display: block; padding: 15px 20px; border: 1px solid #333333; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;"> <b><!--[if mso]>&nbsp;<![endif]-->A Button<!--[if mso]>&nbsp;<![endif]--></b> </a> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td height="30" style="font-size: 0; line-height: 0;">&nbsp;</td> </tr> </table> </td> </tr> <!-- Two Columns, With Padding ==> Stacked Layout : END --> <!-- Two Columns, One Column Without Padding ==> Stacked Layout : BEGIN --> <tr> <td style="border-bottom: 1px solid #e5e5e5;"> <table border="0" width="100%" cellpadding="0" cellspacing="0" align="center" class="fluid"> <tr> <td valign="top" class="hh-force-col"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td style="padding: 30px;font-family: sans-serif; font-size: 16px; line-height: 22px; color: #444444;"> <div style="font-size: 22px;line-height: 1;" class="hh-center">Two Columns, One Column Without Padding</div><br> Two columns; one with padding on all sides and one without padding (good for flush images or columns with a background). Columns stack on narrow screens, maintaining said padding.<br><br> <table cellspacing="0" cellpadding="0" border="0" class="button" style="margin: 0;"> <tr> <td style="-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; background-image: url(http://tedgoas.github.io/Cerberus/assets/bg-btn.png); background-position: top left; background-repeat: repeat-x; background-color: #444444; text-align: center;"> <a href="http://www.google.com" style="color: #ffffff; font-family: sans-serif; font-size: 15px; line-height: 15px; text-align: center; text-decoration: none; display: block; padding: 15px 20px; border: 1px solid #333333; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;"> <b><!--[if mso]>&nbsp;<![endif]-->Another Button<!--[if mso]>&nbsp;<![endif]--></b> </a> </td> </tr> </table> </td> </tr> </table> </td> <td valign="top" class="hh-force-col-center"> <img src="http://placehold.it/250x350/888888/7777777" alt="alt text" height="350" width="250" border="0" style="display: block;margin: auto;" class="hh-fluid"> </td> </tr> </table> </td> </tr> <!-- Two Columns, One Column Without Padding ==> Stacked Layout : END --> <!-- Three Column ==> Stacked Wide Layout ==> Stacked Narrow Layout : BEGIN --> <tr> <td style="padding: 30px;"> <table border="0" cellpadding="0" cellspacing="0" class="columns-container"> <tr> <td width="160" style="padding-right: 30px;font-family: sans-serif; font-size: 16px; line-height: 22px;color: #444444;" valign="top" class="force-col"> <img src="http://placehold.it/160/888888/7777777" alt="alt text" align="center" height="160" width="160" border="0" style="display: block;padding-bottom: 10px;" class="col-3-img-r"> <a href="#" style="color:#444444; font-weight:bold">1 of 3 Header</a><br> These columns appear three across on wide screens... </td> <td style="font-size: 0; line-height: 0; display: none;" class="hh-spacer">&nbsp;</td> <td width="160" style="padding-right: 30px;font-family: sans-serif; font-size: 16px; line-height: 22px;color: #444444;" valign="top" class="force-col"> <img src="http://placehold.it/160/888888/7777777" alt="alt text" align="center" height="160" width="160" border="0" style="display: block;padding-bottom: 10px;" class="col-3-img-l"> <a href="#" style="color:#444444; font-weight:bold">2 of 3 Header</a><br> ...but on medium screens, the columns stack but their child text and image appear side by side... </td> <td style="font-size: 0; line-height: 0; display: none;" class="hh-spacer">&nbsp;</td> <td width="160" style="font-family: sans-serif; font-size: 16px; line-height: 22px;color: #444444;" valign="top" class="force-col"> <img src="http://placehold.it/160/888888/7777777" alt="alt text" align="center" height="160" width="160" border="0" style="display: block;padding-bottom: 10px;" class="col-3-img-r"> <a href="#" style="color:#444444; font-weight:bold">3 of 3 Header</a><br> ...and finally everything stacks and centers on narrow screens. </td> </tr> </table> </td> </tr> <!-- Three Column ==> Stacked Wide Layout ==> Stacked Narrow Layout : END --> </table> <!-- Email Container : END --> <!-- Footer : BEGIN --> <table border="0" width="100%" cellpadding="0" cellspacing="0" align="center" class="email-container"> <tr> <td style="text-align: center;padding: 20px;font-family: sans-serif; font-size: 12px; line-height: 18px;color: #888888;"> If you no longer wish to receive these emails, you can <unsubscribe style="color: #444444; padding: 0;text-decoration: underline">unsubscribe</unsubscribe>.<br> Company Name &bull; 123 Fake Street, SpringField, Oregon 97477 US &bull; <span class="mobile_link">(123) 456-7890</span><br><br> </td> </tr> </table> <!-- Footer : END --> </td></tr></table> </body> </html>