如何使表在每一行上使用多行超出了该表的max-width

.table {
font-size: 12px;
border-bottom: 1px solid #dddddd;
color: #8d8d8d;
max-width: 400px;
}
tr {
border-top: 1px solid #C1C3D1;
border-bottom: 1px solid #C1C3D1;
font-size:16px;
font-weight:normal;
text-shadow: 0 1px 1px rgba(256, 256, 256, 0.1);
padding: 7px;
}
tr:last-child td:first-child {
border-bottom-left-radius:3px;
}
tr:last-child td:last-child {
border-bottom-right-radius:3px;
}
td {
background:#FFFFFF;
vertical-align:middle;
word-wrap:break-word;
text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.1);
border-right: 1px solid #C1C3D1;
padding: 7px;
}<pre>
<table id="TBLTBLDATA" border="1" cellpadding="0" cellspacing="0" class="table" style="position: relative;z-index: 100; width: 296px; height: 26px; padding: 0; font-weight: normal; font-style: normal; text-decoration: none;font-size: 13px; ">
<tr><td valign="middle" align="left" class="table" style="white-space: nowrap;position:static;">TEST</td><td valign="middle" align="left" class="table" style="white-space: nowrap;position:static;">TEST</td><td valign="middle" align="left" class="table" style="white-space: nowrap;position:static;">TEST</td><td valign="middle" align="left" class="table" style="white-space: nowrap;position:static;">TEST</td><td valign="middle" align="left" class="table" style="white-space: nowrap;position:static;">Data</td></tr>
<tr><td valign="middle" align="left" class="table" style="white-space: nowrap;position:static;">123</td><td valign="middle" align="left" class="table" style="white-space: nowrap;position:static;">XXX</td><td valign="middle" align="left" class="table" style="white-space: nowrap;position:static;">0000000</td><td valign="middle" align="left" class="table" style="white-space: nowrap;position:static;">57-41</td><td valign="middle" align="left" class="table" style="white-space: nowrap;position:static;">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</td></tr></table></pre>
发布于 2015-12-27 20:49:03
我会给你两个解决方案。
在表单元格中静态创建的文本
TD Cell中的文本是在开发网站时给出的,而不是由XML响应自动创建的。然后根据http://www.uwec.edu/help/html/tb-multiline.htm的说法,这是你的答案:
当单个表单元格中的文本超过几个单词时,换行符()可以改善表格的外观和可读性。换行符代码允许将数据拆分为多行。将换行代码放在文本中要换行的位置。请注意,在下面的示例中,换行符代码可以在数据单元格中使用,也可以在标题中使用。
请记住,您的文档的用户拥有对字体和大小的最终控制权。某些换行符代码虽然适用于您的首选项设置,但在其他情况下可能不合适。
在表单元格中动态创建的文本
否则,如果单元格中的文本是动态的,并且您不知道它的实际大小,则可以进行以下操作:
文本换行:正常;自动换行:换行;
发布于 2015-12-27 21:09:16
只需将word-wrap: break-word;添加到您的td CSS。如果只想使用一行并隐藏额外的符号,请使用overflow: hidden;
https://stackoverflow.com/questions/34480384
复制相似问题