【发布时间】:2017-11-02 08:16:25
【问题描述】:
我需要在 <td> 元素中换行文本,但我不能使用 css table-layout 属性,因为输出是 html 电子邮件正文并且 Outlook 不支持 table-layout 属性。
是否有其他方法可以在 <td> 元素中包装文本,还是我需要在代码中手动进行换行和测量?
这是我想要实现的一个示例:
td {
border: solid black 1pt;
font-family: arial;
font-size: 10pt
}
thead td{
text-align:center;
font-weight:bold;
}
table {
border-collapse: collapse
}
<html>
<body>
<table style="width:35pt;height:24pt;table-layout:fixed">
<thead>
<tr>
<td style="width:35pt;height:12pt">Good</td>
</tr>
</thead>
<tbody>
<tr>
<td style="width:35pt;height:12pt;word-wrap:break-word">Costingly Cost Cost</td>
</tr>
</tbody>
</table>
<div style="height:50pt"></div>
<table style="width:35pt;height:24pt;">
<thead>
<tr>
<td style="width:35pt;height:12pt">Bad</td>
</tr>
</thead>
<tbody>
<tr>
<td style="width:35pt;height:12pt" nowrap>Costingly Cost Cost</td>
</tr>
</tbody>
</table>
</body>
</html>
【问题讨论】:
-
试试这个方法:HTML TD wrap text。我知道它不是用于电子邮件,而是用于一般表格。
-
不幸的是,这不好。所有提议的解决方案都依赖于使用
table-layout或max-widthcss 属性; Outlook 都不支持这两种方法。 -
这是用于电子邮件的:stackoverflow.com/questions/10096012/…
-
这个建议似乎对我有用,如果你想把它写下来作为答案,我很乐意接受。
-
下面为你添加答案
标签: html html-table html-email