Skip to content

Instantly share code, notes, and snippets.

@Cale
Created August 26, 2014 15:18
Show Gist options
  • Save Cale/4f96cdb155d3e3331162 to your computer and use it in GitHub Desktop.
Save Cale/4f96cdb155d3e3331162 to your computer and use it in GitHub Desktop.
Responsive HTML email template
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
@media screen and (max-width: 480px) {
/* Keep iOS Mail from auto adjusting text-size */
html { -webkit-text-size-adjust: none; }
/* Bump up default text size for mobile */
p {
font-size:25px !important;
}
/* Set tables with specific width to 100% */
*[class].mobile-width {
width:100% !important;
padding-left:20px;
padding-right:20px;
}
/* Stack table columns top to bottom, starting with the left most column. */
*[class].mobile-stack {
display:block !important;
width:100% !important;
}
/* Make images in Layouts fluid */
*[class].fluid-image {
max-width: 100%;
height: auto;
margin:0 auto;
}
/* On mobile displays, hide elements with this class */
*[class].mobile-hide { display:none !important; }
/* Change up our footer text. */
*[class].footer{ font-size:38px !important; text-align:center !important; font-weight:bold !important; }
}
</style>
</head>
<body style="margin:0; padding:0; width:100%; background-color:#f1efef;">
<center>
<table width="550" border="1" cellspacing="0" cellpadding="0" style="background-color: #f1efef;" class="mobile-width">
<tr>
<td>
<img src="http://assets.midnightcheese.com/images/mountains-email.jpg" width="550" class="fluid-image" style="display:block;">
</td>
</tr>
<tr>
<td valign="top" style="padding:15px 0px 15px 0px;" align="left">
<table width="550" class="mobile-width">
<tr>
<td class="mobile-stack" width="50%"><p><b>Column 1</b><br>This is some basic content for our left column. This column will stack above the right column on mobile.</p></td>
<td class="mobile-stack" width="50%"><p><b>Column 2</b><br>This is some basic content for our right column. This column willstack below the left column on mobile.</p></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="footer">
<p>Footer text</p>
</td>
</tr>
</table>
</center>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment