我正在创建一个时事通讯,我发现了一些奇怪的行为.
我有一个2里面的表,我希望它们是一个块和100%宽度,但发生以下情况:
它还打破了邮件的其他部分.我已经尝试了很多……每个视口,最大宽度,最小宽度,我不知道该做什么……
我验证了,媒体查询正在运行
我需要一些特殊的黑客吗?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns:v="urn:schemas-microsoft-com:vml" style="Box-sizing: border-Box;"> <head> <Meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <Meta name="viewport" content="user-scalable=no,width=device-width,initial-scale=1,maximum-scale=1" /> <Meta name=”x-apple-disable-message-reformatting” /> <Meta property="og:title" content="*|MC:SUBJECT|*"> <title>*|MC:SUBJECT|*</title> <style type="text/css">.inhalt li a {line-height:26px;}</style> <style type="text/css"> body { font-family: "Helvetica","Arial"; } img { margin: 0; padding: 0; border: none; } body { color: #000000; z-index: -3; font-family: "Helvetica","Arial"; } @media only screen and (max-width: 599px) { table[yahoo] { display: block; width: 100% !important; min-width: 100% !important; max-width: 100% !important; } .yahoo { display: block; width: 100% !important; min-width: 100% !important; max-width: 100% !important; } .desktop { display: none !important; height: 0px !important; max-height: 0 !important; line-height: 0px !important; font-size: 0px !important; overflow: hidden !important; mso-hide: all; } [desktop] { display: none !important; height: 0px !important; max-height: 0 !important; line-height: 0px !important; font-size: 0px !important; overflow: hidden !important; mso-hide: all; } .mobile { height: auto !important; max-height: none !important; line-height: normal !important; font-size: medium !important; overflow: visible !important; mso-hide: none !important; } [mobile] { height: auto !important; max-height: none !important; line-height: normal !important; font-size: medium !important; overflow: visible !important; mso-hide: none !important; } .mobileshow_inlineblock { height: auto !important; max-height: none !important; line-height: normal !important; font-size: medium !important; overflow: visible !important; mso-hide: none !important; } [mobileshow_inlineblock] { height: auto !important; max-height: none !important; line-height: normal !important; font-size: medium !important; overflow: visible !important; mso-hide: none !important; } .mobile { display: block !important; } [mobile] { display: block !important; } .mobileshow_inlineblock { display: inline-block !important; } [mobileshow_inlineblock] { display: inline-block !important; } .hidden { display: none !important; } .mblock { position: relative; display: table-row !important; } .mblock > tr { display: block; width: 100% !important; max-width: 100% !important; min-width: 100% !important; } .mblock > tr > td { display: block; width: 100% !important; max-width: 100% !important; min-width: 100% !important; } .underlined { text-decoration: underline !important; } .mcol { width: 100% !important; padding: 0 20px !important; } .halfcol { width: 120px !important; } .prehead td { height: 66px !important; } .logo { width: 115px !important; height: 26px !important; } .preheadtxt { font-size: 8px !important; line-height: 11px !important; } .header_image { width: 100% !important; max-width: 100% !important; height: auto !important; } .headertxt { font-size: 16px !important; line-height: 24px !important; } .inhalttitle { font-size: 28px !important; line-height: 36px !important; } .inhaltlinks a { font-size: 16px !important; line-height: 24px !important; text-decoration: none !important; } .teaser { width: 100% !important; max-width: 100% !important; min-width: 100% !important; } .pretitle { font-size: 16px !important; line-height: 20px !important; } .teasertitle { font-size: 28px !important; line-height: 36px !important; } .posttitle { font-size: 16px !important; line-height: 20px !important; } .teasertxt { font-size: 16px !important; line-height: 24px !important; } .mcol_teaser_1_pic { width: 100% !important; text-align: right; } .mcol_teaser_2_pic { width: 100% !important; padding-bottom: 20px !important; } .teaserpic { height: auto !important; width: 100% !important; max-width: 100% !important; min-width: 100% !important; } .smallteaserlink { font-size: 22px !important; } .smallteaserpic { max-width: 100% !important; width: 100% !important; height: auto !important; } .footer .mcol a { text-decoration: underline !important; } .footer_leftpart { font-size: 16px !important; line-height: 34px !important; } .footer_rightpart { text-align: left !important; } .footer_copyright { width: 280px !important; padding: 0 20px !important; text-align: left; position: absolute; top: 100%; left: 0; } .type1 { font-size: 16px !important; line-height: 34px !important; } .type2 { font-size: 16px !important; line-height: 24px !important; } } </style> </head> <body bgcolor="#D8D8D8" style="Box-sizing: border-Box; font-family: 'Helvetica','Arial'; color: #000000; z-index: -3; margin: 0; padding: 0;"> <table bgcolor="#FFFFFF" class="body" cellspacing="0" cellpadding="0" yahoo="1" style="Box-sizing: border-Box; border-collapse: collapse; font-size: 0; width: 600px; margin: 0 auto; padding: 0; border: none;"> <tr style="Box-sizing: border-Box;"> <td align="left" valign="top" cellspacing="0" cellpadding="0" mainwrap style="Box-sizing: border-Box; margin: 0; padding: 0;"> <!-- // Begin Template teasertype2 \\ --> <table yahoo width="600" class="mblock teaser teaser_2 yahoo" bgcolor="#ffffff" style="Box-sizing: border-Box; border-collapse: collapse; font-size: 0; width: 600px; margin: 0; padding: 0; border: none;"> <tr style="Box-sizing: border-Box;"> <td width="260" class="mblock mcol" align="left" valign="top" style="Box-sizing: border-Box; margin: 0; padding: 0;"> <div class="txt pretitle" style="font-size: 12px; line-height: 14px; font-weight: bold; Box-sizing: border-Box; mso-line-height-rule: exactly; color: #000000; font-family: Helvetica,Arial,sans-serif; margin: 0; padding: 0;" mc:edit="pretitle2"> LEFT </div> </td> <td width="260" class="mblock mcol" align="left" valign="top" style="Box-sizing: border-Box; margin: 0; padding: 0;"> <div class="txt pretitle" style="font-size: 12px; line-height: 14px; font-weight: bold; Box-sizing: border-Box; mso-line-height-rule: exactly; color: #000000; font-family: Helvetica,sans-serif; margin: 0; padding: 0;" mc:edit="pretitle2"> RIGHT </div> </td> </tr> </table> <!-- // End Template teasertype2 \\ --> <!--[if !mso]><!--> <!--<![endif]--> </td> </tr> </table> </body> </html>@H_502_13@目前的问题:
iOS 10不接受“display:block;”在“td”标签上
解决方法
我无法确切地告诉您问题的确切位置,但可以在上面提供的代码中看到很多重复.可能存在冲突,特异性问题,或iOS邮件只是让人感到困惑并抛出一个重要的CSS规则.
以下是600px宽电子邮件的简化示例,其中包含两个堆叠的偶数列.我没有包含大部分CSS(与此问题无关)以及大部分周围的HTML.我还删除了孤儿<! - [if!mso]><! - ><! - <![endif] - >在末尾.
要进入< head>的CSS:
<style> @media screen and (max-width: 600px) { .mblock { display: block !important; width: 100% !important; max-width: 100% !important; direction: ltr !important; } } </style>@H_502_13@和HTML:
<!-- // Begin Template teasertype2 \\ --> <table role="presentation" cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#ffffff" align="center" height="100%" valign="top" width="100%"> <!--[if mso]> <table role="presentation" border="0" cellspacing="0" cellpadding="0" align="center" width="600"> <tr> <td align="center" valign="top" width="600"> <![endif]--> <table role="presentation" border="0" cellpadding="0" cellspacing="0" align="center" width="100%" style="max-width:600px;"> <tr> <td align="center" valign="top" style="font-size:0;"> <!--[if mso]> <table role="presentation" border="0" cellspacing="0" cellpadding="0" align="center" width="100%"> <tr> <td align="left" valign="top" width="300"> <![endif]--> <div style="display:inline-block; margin: 0 -2px; width:100%; min-width:200px; max-width:300px; vertical-align:top;" class="mblock"> <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td class="txt pretitle" style="font-size: 12px; line-height: 14px; font-weight: bold; Box-sizing: border-Box; mso-line-height-rule: exactly; color: #000000; font-family: Helvetica,sans-serif; margin: 0; padding: 0;" mc:edit="pretitle2"> LEFT </td> </tr> </table> </div> <!--[if mso]> </td> <td align="left" valign="top" width="300"> <![endif]--> <div style="display:inline-block; margin: 0 -2px; width:100%; min-width:200px; max-width:300px; vertical-align:top;" class="mblock"> <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td class="txt pretitle" style="font-size: 12px; line-height: 14px; font-weight: bold; Box-sizing: border-Box; mso-line-height-rule: exactly; color: #000000; font-family: Helvetica,sans-serif; margin: 0; padding: 0;" mc:edit="pretitle2"> RIGHT </td> </tr> </table> </div> <!--[if mso]> </td> </tr> </table> <![endif]--> </td> </tr> </table> <!--[if mso]> </td> </tr> </table> <![endif]--> </td> </tr> </table> <!-- // End Template teasertype2 \\ -->@H_502_13@这种技术使用混合方法,它使用最大宽度和最小宽度来施加刚性基线(允许一些移动)并为Outlook装入固定的宽宽度,无论如何都被束缚到桌面(因此<! - [if !mso]>东西).媒体查询可以在支持它的客户端(例如iOS Mail)中进一步增强电子邮件.
编辑:其他doctype和元信息:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <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 --> <Meta name="x-apple-disable-message-reformatting"> <!-- Disable auto-scale in iOS 10 Mail entirely --> </head>@H_502_13@