在 IE8 中它工作正常。在 Firefox 中,如果我从 td 中删除 nowrap 属性,文本将被正确包装但不删除 nowrap 文本将不会被包装。
有什么方法可以在 firefox 中通过 css 覆盖 nowrap 属性。
<div style="width:100%;border:1px solid #eaeaea">
<table style="width:100%;word-wrap:break-word;table-layout:fixed" border="1" >
<tr>
<td>
thisssssssssssssssssssssssssss
</td>
<td nowrap="" style="word-wrap:break-word;">
22222222thisssssssssssssssssssssssssss22222222thisssssssssssssssssssssssssss22222222thisssssssssssssssssssssssssss
</td>
</tr>
</table>
</div>
最佳答案
table {
table-layout:fixed;
width:100%;
word-wrap:break-word;
}
td {
white-space: normal;
}
white-space 规则覆盖 no-wrap 属性(你的问题),word-wrap 规则打破牢不可破的字符串
关于html - 如何覆盖表nowrap属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5387931/