我有这个基本的例子,应该在移动设备上将这三个表格单元格显示为块(在彼此之下)。
然而,这似乎不适用于iPad,iPhone和三星手机。它 适用于模拟移动显示的常规浏览器和网站(可能适用于网页),但在移动设备的实际邮件客户端上查看时,display: block
属性似乎被忽略。
有什么遗失的吗?或者如果根本不支持display
- 属性,还有什么选择?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="utf-8">
<title>Mobilize me</title>
<style type="text/css">
@media only screen and (max-width: 1400px) {
table,tr,td{
width: 100% !important;
display: block !important;
clear: both !important;
}
}
</style>
</head>
<body>
<table cellspacing="0" cellpadding="0" width="900">
<tr>
<td width="33%" bgcolor="red">
one
</td>
<td width="33%" bgcolor="green">
two
</td>
<td width="33%" bgcolor="blue">
three
</td>
</tr>
</table>
</body>
</html>
值得注意的是,来自example的this thread也无效。
答案 0 :(得分:1)
我认为,在撰写本文时,可以安全地断定这种技术已经或者已经变得不受支持。
更好的方法是使用2种不同的显示器:一种用于桌面阅读器,一种用于移动阅读器,如下所示(测试和工作):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.ReadMsgBody {
width: 100%;
}
.ExternalClass {
width: 100%;
}
a:hover,
a:visited,
a:active {
color: #ffffff;
}
@media screen and (max-width: 480px), screen and (max-device-width: 480px) {
body { -webkit-text-size-adjust: none;}
div[id=desktop] {
display:none !important;
width:0px !important;
overflow:hidden !important;
}
div[id=mobile] {
display:block !important;
width:100% !important;
height:auto !important;
max-height:inherit !important;
overflow:visible !important;
}
div[id=mobile] table{
display: block !important;
overflow: auto;
}
div[id=mobile] img{
width: 100%;
}
-->
</style>
<style type="text/css">
div.online p {margin:0; padding:0; margin-bottom:0;}
div.online a:link, div.online a:visited, div.online a:hover, div.online a:active { color: #333333; }
</style>
</head>
<body bgcolor="#e6e6e6" style="margin:0;">
<div class="online" style="margin:10px auto; color: #333333; font-family: verdana; font-size:11px;text-align:center;">
<a href="http://somedomain.com/some/page.htm?lang=nl" target="_blank" style="text-decoration: none; color: #333333;">View in browser</a>
</div>
<div id="desktop">
<table cellpadding="10" cellspacing="0" border="0" style="width:100%; background-color:#e6e6e6;">
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0" border="0" style="width:620px; background-color:#ffffff; text-align:left;">
<tr>
<td>
<table cellpadding="0" cellspacing="20" border="0" style="width:620px; text-align:left; background-color:#ffffff;">
<tr>
<td><a href="#" target="_blank"><img src="https://www.domain.com/x-http://somedomain.com/some/page/img/props/header.jpg" border="0" style="display:block;" /></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="20" border="0">
<tr>
<td valign="top"><img src="https://www.domain.com/x-http://somedomain.com/some/page/img/props/00f_1.gif" style="max-width: 240px;" /></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" border="0" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333333;">
<tr>
<td style="font-size:22px; color:#fea900;">Block 1</td>
</tr>
<tr>
<td><img src="https://www.domain.com/x-http://somedomain.com/some/page/img/props/filler12.png" /></td>
</tr>
<tr>
<td>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="20" border="0">
<tr>
<td valign="top"><img src="https://www.domain.com/x-http://somedomain.com/some/page/img/props/0f0_1.gif" style="max-width: 240px;" /></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" border="0" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333333;">
<tr>
<td style="font-size:22px; color:#fea900;">Block 2</td>
</tr>
<tr>
<td><img src="https://www.domain.com/x-http://somedomain.com/some/page/img/props/filler12.png" /></td>
</tr>
<tr>
<td>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" style="border-bottom: 2px dotted #666666;"><img src="https://www.domain.com/x-http://somedomain.com/some/page/img/props/filler12.png" /></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div id="mobile" style="display:none; width:0px; max-height:0px; overflow:hidden;">
<table cellpadding="10" cellspacing="0" border="0" style="width:100%; background-color:#e6e6e6; display:none;">
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; background-color:#ffffff; text-align:left; display:none;">
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; text-align:left; background-color:#ffffff; display:none;">
<tr>
<td><a href="#" target="_blank"><img id="header" src="https://www.domain.com/x-http://somedomain.com/some/page/img/props/header.jpg" border="0" style="display:block;" /></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="10" border="0" style="display:none;">
<tr>
<td>
<table cellpadding="0" cellspacing="10" border="0" style="font-family:Arial; font-size:14px; color:#333333; display:none;">
<tr>
<td><img src="https://www.domain.com/x-http://somedomain.com/some/page/img/props/00f_1.gif" /></td>
</tr>
<tr>
<td style="font-size:20px; color:#fea900;">Block 1</td>
</tr>
<tr>
<td>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="10" border="0" style="display:none;">
<tr>
<td>
<table cellpadding="0" cellspacing="10" border="0" style="font-family:Arial; font-size:14px; color:#333333; display:none;">
<tr>
<td><img src="https://www.domain.com/x-http://somedomain.com/some/page/img/props/0f0_1.gif" /></td>
</tr>
<tr>
<td style="font-size:20px; color:#fea900;">Block 2</td>
</tr>
<tr>
<td>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" style="border-bottom: 2px dotted #666666;"> </td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div class="online" style="margin: 10px auto 25px; color: #333333; font-family: verdana; font-size:11px;text-align:center;">
<p align="center">
<a href="http://somedomain.com/some/page.htm?lang=nl" target="_blank" style="text-decoration: none; color: #333333;">Unsubscribe</a> -
<a href="http://somedomain.com/some/page.htm?lang=nl" target="_blank" style="text-decoration: none; color: #333333;">Edit profile</a>
</p>
<p align="center" style="margin-top: 15px;"></p>
</div>
</body>
</html>
答案 1 :(得分:1)
使用带有“align =”的三个嵌套表来复制“float”,并使用媒体查询将表调整为100%,并在移动设备上显示:block。
我添加了类来区分容器和块表。还添加了几个内联样式来帮助。
E.G。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="utf-8">
<title>Mobilize me</title>
<style type="text/css">
@media only screen and (max-width: 900px) {
.container {
width: 100% !important;
text-align:center !important;
}
.blocktable {
width: 100% !important;
display: block !important;
margin: 0 auto !important;
}
}
</style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" width="900" class="container" style="border-collapse:collapse;">
<tr>
<td align="center">
<table align="left" bgcolor="RED" cellspacing="0" cellpadding="0" border="0" width="33%" class="blocktable" style="border-collapse:collapse;">
<tr>
<td>one</td>
</tr>
</table>
<table align="left" bgcolor="GREEN" cellspacing="0" cellpadding="0" border="0" width="34%" class="blocktable" style="border-collapse:collapse;">
<tr>
<td>two</td>
</tr>
</table>
<table align="right" bgcolor="BLUE" cellspacing="0" cellpadding="0" border="0" width="33%" class="blocktable" style="border-collapse:collapse;">
<tr>
<td>three</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>