简体   繁体   English

尽管使用了break all和break word,但是word warp在html中不起作用

[英]word warp not working in html despite using break all and break word

I am using below code in my project for wrapping the text but the text is still overflowing to the next text box. 我在项目中使用下面的代码包装文本,但是文本仍然溢出到下一个文本框。 I also tried using word-wrap:break-all but it did not work. 我也尝试使用word-wrap:break-all但是没有用。 I am using Chrome to test my code. 我正在使用Chrome来测试我的代码。

Can anyone suggest what should I use to wrap text in this scenario? 在这种情况下,谁能建议我使用什么来包装文本?

Code : 代码

<td style="word-wrap:break-word" <%if((sv.ownername).getClass().getSimpleName().equals("ZonedDecimalData")) {%>align="right"<% }else {%> align="left" <%}%> ><%=smartHF.getHTMLOutputFieldSFL(sv.ownername, "ownername", 0)%></td>

add this one 加这个

word-break: break-all;  
white-space:normal;

You can use this html 您可以使用此html

<table width="100" border="1" style="table-layout:fixed">
  <tr>
    <td><div style="word-wrap:break-word"> 23232323232323232323232323232323232323232323232323</div></td>
    <td>abcabc</td>
  </tr>
</table>

You should give width to the text holder so that word-wrap will work 您应该给文本持有人一个宽度,以便自动换行

 p.test { width: 100px; border: 1px solid #000000; word-wrap: break-word; } 
 <table> <tr> <td> <p class="test"> I am using below code in my project for wrapping the text but the text is still overflowing to the next text box. I also tried using word-wrap:break-all but it did not work. I am using Chrome to test my code.</p> </td> </tr> </table> 

I had struggled with a similar issue for a while and finally realized that a parent container's height was limited and its overflow property was set to hidden. 我在类似问题上苦苦挣扎了一段时间,终于意识到父容器的高度受到限制,并且其溢出属性被设置为隐藏。

After allowing the parent to be taller I finally was able to see the text. 在允许父母长高之后,我终于能够看到文字。

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM