在响应式电子邮件中无法正确堆叠

时间:2015-11-25 14:25:41

标签: html-email responsive-emails

所以我试图建立我的第一个响应式电子邮件,除了我的两个导航区域外,一切都很顺利。第一个,我有四个按钮,我想从跑步中重新排列,到堆叠两个ontop两个。它在我的初始测试中起作用,但是当我通过我的电子邮件提供商发送它时,前两个tds正确呈现(均为50%)但是应该放在下面的两个都被挤压到一边。对于我试图做的第二次导航也是如此(除了我希望三者在彼此之上切换到100%)

如何解决此问题的任何建议将不胜感激!这是我的代码(在这里工作得很好,但是当我实际发送时,它在所有手机上都有用):



/* Stacked Top Links Navigation Pattern CSS */
@media only screen and (max-width: 400px) {
    td[class="main_nav"] {
        padding: 0;
    }
    td[class="main_nav"] td {
        display: inline-block;
        /*float: left;*/
        padding: 0 !important;
        width: 50%;
    }
    td[class="main_nav"] a {
        display: block;
        padding: 10px 0;
        background: #565656;
    }
    td[class="main_nav"] .nav1 a,
    td[class="main_nav"] .nav2 a {
        border-bottom: 1px solid #777;
    }
    td[class="main_nav"] .nav1 a,
    td[class="main_nav"] .nav3 a {
        border-right: 1px solid #777;
    }
}

/* Stacked Top Links Navigation Pattern CSS */
@media only screen and (max-width: 400px) {
    td[class="secondary_nav"] {
        padding: 0;
    }
    td[class="secondary_nav"] td {
        display: inline-block;
        /*float: left;*/
        padding: 0 !important;
        width: 100%;
    }
    td[class="secondary_nav"] a {
        display: block;
        padding: 10px 0;
        background: #005c5b;
        text-align: center;
    }
    td[class="secondary_nav"] .nav1 a,
    td[class="secondary_nav"] .nav2 a {
        border-bottom: 1px solid #fff;
    }
}

 <!-- BEGINNING OF NAVIGATION -->
  <table cellpadding="0" cellspacing="0" bgcolor="#565656">
      <tr>
          <td class="main_nav" width="600" bgcolor="#565656">
              <table cellpadding="0" cellspacing="0" width="100%" bgcolor="#565656" style="width:100%!important">
                  <tr>
                      <td class="nav1" align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                          <a href="#" style="text-decoration: none; color: #ffffff;">Nav 1</a>
                      </td>
                      <td class="nav2" align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                       <a href="#" style="text-decoration: none; color: #ffffff;">Nav 2</a>
                      </td>
                      <td class="nav3" align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                       <a href="#" style="text-decoration: none; color: #ffffff;">Nav 3</a>
                      </td>
                      <td align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                       <a href="#" style="text-decoration: none; color: #ffffff;">Nav 4</a>
                      </td>
                  </tr>
              </table>
          </td>
      </tr>
  </table>
  <br/>
  <!-- END OF NAVIGATION -->

<!-- BEGINNING OF SECONDARY STORY NAVIGATION -->
<table cellpadding="0" cellspacing="0" style="border-collapse:collapse;">
    <tr>
        <td class="secondary_nav" width="600">
            <table cellpadding="0" cellspacing="0" width="100%" bgcolor="#005c5b">
                <tr>
                    <td class="nav1" width="33.33%" align="center" style="padding: 20px 10px 20px 30px; text-align:left;border-right:solid 1px #ffffff;">
                        <a href="bottom-section" style="font-family:arial; font-weight:bold; font-size:14px;color:#ffffff; text-decoration:none;">Secondary nav 1</a>
                    </td>
                    <td class="nav2" width="33.33%" align="center" style="padding: 20px 10px 20px 30px; font-family: arial,sans-serif; font-size: 11px; text-align:left;border-right:solid 1px #ffffff;">
                        <a href="bottom-section" style="font-family:arial; font-weight:bold; font-size:14px;text-decoration: none; color: #ffffff;">Secondary nav 2</a>
                    </td>
                    <td class="nav3" width="33.33%" align="center" style="padding: 20px 10px 20px 30px; font-family: arial,sans-serif; font-size: 11px; text-align:left;">
                        <a href="bottom-section" style="font-family:arial; font-weight:bold; font-size:14px;text-decoration: none; color: #ffffff;">Secondary nav 3</a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

<!-- END OF SECONDARY STORY NAVIGATION -->
                  
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

我建议换一下对齐表格的内联单元格。细胞不会在50%的情况下发挥出色,你总是需要在这之下。这样说,您的单元格永远不会正确对齐,您将在下面的版本中看到。

使用对齐表格的一个缺点是,您需要在表格周围添加鬼表,以确保Outlook尊重您想要的紧密对齐,并且不会添加所需的20px余量表之间。

我只对原始单元格宽度进行了调整,在标题CSS中调整了49%,然后在原始代码下面的新行中创建了对齐的表格版本,并在我的包装表中添加了一个新的main_nav_inner类。 / p>

&#13;
&#13;
<!DOCTYPE HTML>
<html>
<head>
    
	<style type="text/css">
		/* Stacked Top Links Navigation Pattern CSS */
		@media only screen and (max-width: 400px) {
			td[class="main_nav"] {
				padding: 0;
			}
			td[class="main_nav"] td {
				display: inline-block;
				/*float: left;*/
				padding: 0 !important;
				width: 49%;
			}
			td[class="main_nav2"] .main_nav_inner table {
				width: 50%!important;
			}
			td[class="main_nav"] a {
				display: block;
				padding: 10px 0;
				background: #565656;
			}
			td[class="main_nav"] .nav1 a,
			td[class="main_nav"] .nav2 a,
			td[class="main_nav2"] .main_nav_inner .nav1,
			td[class="main_nav2"] .main_nav_inner .nav2  {
				border-bottom: 1px solid #777;
			}
			td[class="main_nav"] .nav1 a,
			td[class="main_nav"] .nav3 a,
			td[class="main_nav2"] .main_nav_inner .nav1,
			td[class="main_nav2"] .main_nav_inner .nav3 {
				border-right: 1px solid #777;
			}
		}
		
		/* Stacked Top Links Navigation Pattern CSS */
		@media only screen and (max-width: 400px) {
			td[class="secondary_nav"] {
				padding: 0;
			}
			td[class="secondary_nav"] td {
				display: inline-block;
				/*float: left;*/
				padding: 0 !important;
				width: 100%;
			}
			td[class="secondary_nav"] a {
				display: block;
				padding: 10px 0;
				background: #005c5b;
				text-align: center;
			}
			td[class="secondary_nav"] .nav1 a,
			td[class="secondary_nav"] .nav2 a {
				border-bottom: 1px solid #fff;
			}
		}
	</style>
</head>
<body style="min-width: 100%; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-right: 0px" yahoo="fix">
<!-- BEGINNING OF NAVIGATION -->
  <table cellpadding="0" cellspacing="0" bgcolor="#565656" width="100%">
      <tr>
          <td class="main_nav" bgcolor="#565656">
              <table cellpadding="0" cellspacing="0" width="100%" bgcolor="#565656" style="width:100%!important">
                  <tr>
                      <td class="nav1" align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                          <a href="#" style="text-decoration: none; color: #ffffff;">Nav 1</a>
                      </td>
                      <td class="nav2" align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                       <a href="#" style="text-decoration: none; color: #ffffff;">Nav 2</a>
                      </td>
                      <td class="nav3" align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                       <a href="#" style="text-decoration: none; color: #ffffff;">Nav 3</a>
                      </td>
                      <td class="nav4" align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                       <a href="#" style="text-decoration: none; color: #ffffff;">Nav 4</a>
                      </td>
                  </tr>
              </table>
          </td>
      </tr>
      <tr>
          <td class="main_nav2" bgcolor="#565656">
              <table cellpadding="0" cellspacing="0" width="100%" bgcolor="#565656" style="width:100%!important">
                  <tr>
                  	<td class="main_nav_inner">
                         <!--[if gte mso 9]>
                            <table border="0" cellpadding="0" cellspacing="0" style="width:600px;">
                                <tr>
                                    <td valign="top" style="width:150px;">
                        <![endif]-->
                    	<table align="left" class="nav1" border="0" cellpadding="0" cellspacing="0" style="width:25%;">
                            <tr>
                                <td align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                                      <a href="#" style="text-decoration: none; color: #ffffff;">Nav 1</a>
                                  </td>
                            </tr>
                        </table>
                        <!--[if gte mso 9]>
                                    </td>
                                    <td valign="top" style="width:150px;">
                        <![endif]-->
                    	<table align="left" class="nav2" border="0" cellpadding="0" cellspacing="0" style="width:25%;">
                            <tr>
                                <td align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                                   <a href="#" style="text-decoration: none; color: #ffffff;">Nav 2</a>
                                  </td>
                            </tr>
                        </table>
                        <!--[if gte mso 9]>
                                    </td>
                                    <td valign="top" style="width:150px;">
                        <![endif]-->
                    	<table align="left" class="nav3" border="0" cellpadding="0" cellspacing="0" style="width:25%;">
                            <tr>
                                <td align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                                   <a href="#" style="text-decoration: none; color: #ffffff;">Nav 3</a>
                                  </td>
                            </tr>
                        </table>
                        <!--[if gte mso 9]>
                                    </td>
                                    <td valign="top" style="width:150px;">
                        <![endif]-->
                    	<table align="left" class="nav4" border="0" cellpadding="0" cellspacing="0" style="width:25%;">
                            <tr>
                                <td align="center" style="padding: 10px 10px; font-family: arial,sans-serif; font-size: 11px;">
                                   <a href="#" style="text-decoration: none; color: #ffffff;">Nav 4</a>
                                  </td>
                            </tr>
                        </table>
                        <!--[if gte mso 9]>
                                    </td>
                                </tr>
                            </table>
                        <![endif]-->
                    </td>
                  </tr>
              </table>
          </td>
      </tr>
  </table>
  <br/>
  <!-- END OF NAVIGATION -->

<!-- BEGINNING OF SECONDARY STORY NAVIGATION -->
<table cellpadding="0" cellspacing="0" style="border-collapse:collapse;">
    <tr>
        <td class="secondary_nav" width="600">
            <table cellpadding="0" cellspacing="0" width="100%" bgcolor="#005c5b">
                <tr>
                    <td class="nav1" width="33.33%" align="center" style="padding: 20px 10px 20px 30px; text-align:left;border-right:solid 1px #ffffff;">
                        <a href="bottom-section" style="font-family:arial; font-weight:bold; font-size:14px;color:#ffffff; text-decoration:none;">Secondary nav 1</a>
                    </td>
                    <td class="nav2" width="33.33%" align="center" style="padding: 20px 10px 20px 30px; font-family: arial,sans-serif; font-size: 11px; text-align:left;border-right:solid 1px #ffffff;">
                        <a href="bottom-section" style="font-family:arial; font-weight:bold; font-size:14px;text-decoration: none; color: #ffffff;">Secondary nav 2</a>
                    </td>
                    <td class="nav3" width="33.33%" align="center" style="padding: 20px 10px 20px 30px; font-family: arial,sans-serif; font-size: 11px; text-align:left;">
                        <a href="bottom-section" style="font-family:arial; font-weight:bold; font-size:14px;text-decoration: none; color: #ffffff;">Secondary nav 3</a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

<!-- END OF SECONDARY STORY NAVIGATION -->
</body>
</html>
&#13;
&#13;
&#13;