Android 上的 Html 电子邮件模板没有响应

Riz*_*Riz 5 gmail android html-email responsive-design

我使用表格、tr、td 创建了一个电子邮件模板。一切似乎都很好,除了在 Android 手机上它没有重新调整大小以适应屏幕这一事实。它在苹果产品上完美运行。我在网上搜索了一些,这个词似乎是 Android 已经禁用了某些产品的响应能力原因。必须有办法解决这个问题,因为大多数电子邮件都是在手机上查看的,其中不少是在 Android 上查看的。

Ted*_*oas 0

正如其他一些人所指出的,Gmail 和一些Android 现有电子邮件客户端不支持媒体查询。为了覆盖这些客户,您需要混合设计

混合设计无需使用媒体查询即可实现响应式、变形的布局。其核心是,它使用最大宽度和最小宽度来施加严格的基线(允许一些移动),并为无论如何都束缚在桌面上的 Outlook 施加固定的宽宽度。一旦设置了适合移动设备的基线,媒体查询就会在支持它的客户端(例如 iOS Mail)中进一步增强电子邮件的功能。

以下是来自GitHub 上 Fabio Carneiro 代码示例的基本 2 列脚手架(全部归功于他!):

<!doctype html>
<html>
	<body style="margin:0;">
		<center>
			<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">




				<!-- // 2-COLUMN SCAFFOLD [CENTERING, FLUID] -->
				<tr>
					<td align="center" height="100%" valign="top" width="100%">
						<!--[if mso]>
						<table align="center" border="0" cellspacing="0" cellpadding="0" width="660">
						<tr>
						<td align="center" valign="top" width="660">
						<![endif]-->
						<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:660px;">
							<tr>
								<td align="center" valign="top" style="font-size:0;">
									<!--// DEVELOPER NOTES:
										1. Setting font-size:0; is necessary to ensure
										   that there is no extra spacing introduced
										   between the centering divs that wrap each
										   of the columns. //-->

									<!--[if mso]>
									<table align="center" border="0" cellspacing="0" cellpadding="0" width="660">
									<tr>
									<td align="left" valign="top" width="330">
									<![endif]-->
									<div style="display:inline-block; max-width:50%; min-width:240px; vertical-align:top; width:100%;">
										<!--// DEVELOPER NOTES:
											1. To have each column center upon stacking,
											   wrap them in individual divs, set the same
											   max-width and width as the table within it,
											   and set display to inline-block; using
											   vertical-align is optional.

											2. Setting min-width determines when the two
											   columns of this block will wrap; in this
											   case, when the total available width is
											   less than or equal to 480px. //-->

										<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:330px;">
											<tr>
												<td align="center" valign="top">
	
													<!-- // REPLACE WITH BLOCK -->
													<p style="background-color:#2BAADF; color:#FFFFFF; font:16px Helvetica, sans-serif, normal; margin:0 !important; padding:10px;">LEFT</p>
													<!-- REPLACE WITH BLOCK // -->
	
												</td>
											</tr>
										</table>
									</div>
									<!--[if mso]>
									</td>
									<td align="left" valign="top" width="330">
									<![endif]-->
									<div style="display:inline-block; max-width:50%; min-width:240px; vertical-align:top; width:100%;">
										<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:330px;">
											<tr>
												<td align="center" valign="top">
	
													<!-- // REPLACE WITH BLOCK -->
													<p style="background-color:#51BBE5; color:#FFFFFF; font:16px Helvetica, sans-serif, normal; margin:0 !important; padding:10px;">RIGHT</p>
													<!-- REPLACE WITH BLOCK // -->	
	
												</td>
											</tr>
										</table>
									</div>
									<!--[if mso]>
									</td>
									</tr>
									</table>
									<![endif]-->
								</td>
							</tr>
						</table>
						<!--[if mso]>
						</td>
						</tr>
						</table>
						<![endif]-->
					</td>
				</tr>
				<!-- 2-COLUMN SCAFFOLD [CENTERING, FLUID] // -->




			</table>
		</center>
	</body>
</html>
Run Code Online (Sandbox Code Playgroud)

该仓库和其他地方有更多的脚手架和模式,但这显示了行动的基本原则。