Hop*_*ppe 16 html html-email outlook-2010
我正在接收最终用户输入并将其插入HTML电子邮件中.但是,如果最终用户输入长URL或非常长的单词,则会通过扩展列或div超出指定的宽度来破坏Outlook 2010中的HTML布局.
在Chrome,Firefox,IE7 +和Safari中,我可以使用style ="table-layout:fixed"来强制表格列为特定宽度.但Outlook 2010忽略了这一点,并且长字将表格宽度推出超出固定宽度.
使用Div,Chrome,Firefox,IE7 +和Safari,我可以使用style ="word-wrap:break-word; overflow:hidden; width:100px"来修复div宽度.但在Outlook 2010中,它将div推出超出固定宽度.
如何让outlook2010包含长字,并尊重固定宽度?
这是我的示例HTML:
<!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>
</head>
<body>
<table width="400" style="table-layout: fixed" border="1">
<tr>
<td width="100">
yo
</td>
<td width="300">
Don't move me
</td>
</tr>
</table>
<table width="400" style="table-layout: fixed" border="1">
<tr>
<td width="100" style="word-wrap: break-word; overflow: hidden; width: 100px" border="1">
yoooooooooooooooooooooooooooooooooooooooooooooooooooooo
</td>
<td width="300">
Ya moved me
</td>
</tr>
</table>
<table width="400" border="1">
<tr>
<td width="100">
<div style="word-wrap: break-word; overflow: hidden; width: 100px" border="1">
yoooooooooooooooooooooooooooooooooooooooooooooooooooooo
</div>
</td>
<td width="300">
Ya moved me
</td>
</tr>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
sam*_*red 35
使用Microsoft专有 word-break:break-all;
<td style="word-break:break-all;">
Run Code Online (Sandbox Code Playgroud)
我知道我迟到了,但我可以为其他遇到这篇文章并想要使用该属性的人提出的建议word-break:break-all;是将需要打破的单词包装在 内的元素中<td>,然后应用word-break:break-all;。
就像这样:
<td>Serial #: <a href="#" style="word-break:break-all;">1111222233334444555566667777888899990000</a></td>
Run Code Online (Sandbox Code Playgroud)
在这一点上,您还可以使用其他东西来打破长单词,例如<wbr>元素,或“零宽度空格字符”又名 ZWSP ​,如果您想要在文本中断时使用连字符,请使用­.
检查我在 CodePen 中制作的这个(目前丑陋的><)演示:长字符串单词中的断词。
更多信息请参见以下链接:
<wbr>- MDN - Mozilla 开发者网络希望这可以帮助。