【发布时间】:2015-10-08 17:56:09
【问题描述】:
我试图打破<td> 中的文本。我尝试了一些 poroposed 的解决方案,但似乎它们都不起作用。
可能的重复: Word-wrap
我想断开一个大链接。这是我的代码:
<div style="padding-top: 250px; margin-right: 25px;">
<table style="table-layout:fixed; width:700px;">
<col width="300">
<col width="10">
<col width="10">
<col width="10">
<col width="10">
<thead>
<tr>
<th class="desc">Link</th>
<th class="unit">Price</th>
<th class="qty">Amount</th>
<th class="service">TVA</th>
<th class="total">TOTAL</th>
</tr>
</thead>
<tbody>
<tr>
<td class="desc" style="overflow:hidden; word-wrap: break-word;
word-break: break-all;">Link</td>
<td >price</td>
<td >amount</td>
{% if oProd.tva %}
<td>tva%</td>
{% else %}
<td>TVA non existante</td>
{% endif%}
<td>inal_price</td>
{% set total = total + final_price%}
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="2"></td>
<td colspan="2">Prix final</td>
<td>{{ total }}</td>
</tr>
</tfoot>
</table>
</div>
现在这是我的 desc 的 CSS:
.service .desc h4 {
font-size: 22px;
line-height: 25px;
}
.service .desc {
padding: 0 15px;
overflow: hidden;
}
table .desc {
text-align: left;
background: #D0D0D0;
}
【问题讨论】:
-
您能否发布
.desc的 CSS,您可以尝试使用60%或300em等指定列宽。另外说明,这可能会提高浏览器兼容性td { white-space: pre; /* CSS 2.0 */ white-space: pre-wrap; /* CSS 2.1 */ white-space: pre-line; /* CSS 3.0 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ white-space: -moz-pre-wrap; /* Mozilla */ white-space: -hp-pre-wrap; /* HP Printers */ word-wrap: break-word; /* IE 5+ */ }source -
试试这个:
table tr td, table tr th { page-break-inside: avoid; } -
@Mousey 你觉得我是不是有点过分了?
-
@Matteo 对我不起作用。还有其他建议吗?
-
嗨@BesbesRiadh,对不起,我使用knplabs/knp-snappy-bundle,我的评论是解决同一问题但使用该捆绑包的解决方案....