我有一個測試佈局,使用表格顯示兩列和媒體查詢,它們將兩列堆疊到支持媒體查詢的電子郵件客戶端上。我堅持使用表格而不是divs,因爲我們需要支持Outlook:。在Android 4.3及更低版本(列堆疊)中佈局效果很好,但在Nexus 5(Android 4.4.2)上爆炸。仍然顯示在一起,第二列被完全壓扁,似乎4.4.2不支持在td顯示塊,有沒有其他人經歷過這種情況?如果是,是否有任何解決方法?順便說一句,它似乎只有顯示塊和顯示:內聯塊在Nexus 5上不受支持,如果我在媒體查詢中將tds設置爲display:none,它們隱藏在屏幕上。下面是一個基本的html電子郵件模板,將不起作用:響應HTML電子郵件安卓nexus 5(4.4.2)本機郵件應用程序
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="initial-scale=1.0;width:device-width">
<!-- So that mobile webkit will display zoomed in -->
<title>Email template</title>
<!-- disable auto telephone linking in iOS -->
<meta name="format-detection" content="telephone=no">
<style type="text/css">
@media screen and (max-width:640px) {
table[class="container"] {
width: 100%!important;
}
td[class="cell"] {
background-color: #cc3333;
width: 100%!important;
display: block!important;
}
}
</style>
</head>
<body>
<table width="640" align="center" cellpadding="0" cellspacing="0" class="container">
<tr>
<td class="cell">Hello world</td>
<td class="cell">Hello world</td>
</tr>
</table>
</body>
</html>
編輯1/14因此,使用表作爲塊元素的作品硅。如果寬度小於640像素,表格會浮動(使用對齊)。現在唯一的問題是,當這兩個表換行時,因爲它們的寬度設置爲320px,所以在具有超過320像素但小於640像素的原始分辨率的設備上,文本不會重排爲100%(例如,橫向模式下的iPhone爲480像素),而是包裝在320px(在右邊留下大約160px的空白)。我知道我可以使用媒體查詢更改寬度,但不幸的是它不適用於Gmail應用程序(grrh)。任何想法/建議?簡單的表結構 -
<table align="center" style="width: 640px;max-width:100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<table align="left" style="width:49%;" border="1">
<tr>
<td style="max-width: 100%">long text which should take about 480px
</td>
</tr>
</table>
<table style="width:49%;max-width: 100%" align="left">
<tr>
<td style="width:100%;">long text which should take about 480px
</td>
</tr>
</table>
</td>
</tr>
</table>
我沒有找到與它打交道,使用表並對其施加塊的一種方式如下建議http://stackoverflow.com/questions/17674172/equivalent-to-float-在-前景。這似乎工作,但仍然打開任何其他建議。 – Sachin
上面的鏈接是一種浮動技術,不需要媒體查詢功能。理想情況下,如果您有兩個相同大小的列,儘管您可以隨時在媒體查詢中對其進行調整。但獨立,恕我直言,它是一個非常優秀的技術媒體查詢,因爲它適用於Gmail和其他客戶端沒有MC支持。 (我可能會偏向寫這篇文章的人) – John
@John - 我同意,鑑於大多數使用gmail的人會使用gmail應用程序而不是原生電子郵件應用程序! – Sachin