【发布时间】:2020-05-14 04:27:46
【问题描述】:
我的任务是为 HTML 电子邮件创建模板。我们的设计师(上帝保佑他们)有一个好主意,即创建一个片段,在左侧,我们有一些文本,在右侧有一个图像,大致如下:
在移动设备上,他们希望文本位于图像之后,但我该如何实现呢?我建议使用 2 个标记,但客户不希望这样。我的第二个想法是使用 CSS 属性direction:将其设置为 rtl 并在移动设备上将其切换回 ltr,因此更改顺序。但这失败了,因为彼此相邻的 2 个元素是表格。 Outlook 会忽略表格上的display:inline,因此要使它们彼此相邻,我必须使用align="left"。但是左对齐有点覆盖我的direction: rtl 属性。有人知道吗?
所描述的概念有效,但在 Outlook 中不起作用,表格显示在彼此下方,因为它忽略了display:inline。
(由于我的组件在客户端> 750px宽度和100%的客户端空间中占用了一半空间direction:rtl不会改变顺序元素相互堆叠,仅彼此相邻)
https://codepen.io/hergi/pen/YzPbKzX?editors=1100
<style type="text/css">
.wrapper {
direction: rtl;
}
@media (max-width:749px) {
.wrapper {
direction: ltr !important;
}
}
@media (min-width:750px) {
.wrapper {
direction: rtl !important;
}
}
</style>
<div class="wrapper" style="direction: rtl;">
<table style="display: inline-block;">
<tr>
<td>
<img src="https://kde.org/stuff/clipart/logo/kde-logo-white-blue-rounded-128x128.png" />
</td>
</tr>
</table>
<table style="display: inline-block;">
<tr>
<td>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/59/Google-Cloud-Storage-Logo.svg/128px-Google-Cloud-Storage-Logo.svg.png" />
</td>
</tr>
</table>
</div>
【问题讨论】:
标签: html email templates outlook inline