`

文字和图片把表格撑大的解决方案

    博客分类:
  • Asp
阅读更多
文字输入多了不换行把表格撑大了的修改方法
<table style="word-break: break-all" width="100" border="0" cellspacing="0" cellpadding="0">

图片把表格撑大的问题
<table width="778"style="table-layout:fixed;">
<tr>
    <td>
<img src="logo.gif" border=0 onload="javascript:if(this.width>540)this.width=540;">
    </td>
</tr>
</table>



<table style="table-layout:fixed;">

这样就可以解决表格和层被撑破。但它会把英文词或图片全部被截断了。


table {
table-layout:fixed;
word-break:break-all;
word-wrap:break-word;
}
div {
word-break:break-all;
word-wrap:break-word;
}

就可以解决表格和层被撑破。但它会把英文词全部被截断了。

把它改一下,改为以下的代码
后来我发现上述代码改写一下就可以做到既防止表格/层撑破又防止单词断裂了。
如下:
代码

table {
table-layout: fixed;
word-wrap:break-word;
}
div {
word-wrap:break-word;
}

下面的是将超出范围的字省略?



<table width="200" border="1" style="table-layout: fixed;">
<tr>
<td style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis;">⊙河南省重点建设成就图片展⊙中原文化港澳行,魅力河南图片展⊙中原文化上海行,魅力河南图片展⊙中原文化北京行,魅力河南图片展⊙中原文化广州行,魅力河南图片展⊙中华人民共和国建国50周年成就展
</td>
</tr>
</table>



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics