简体   繁体   English

使一长行文本实际上在基于%的div上中断

[英]Getting a long line of text to actually break on a % based div

I am trying to get it so that if a long string of characters are entered in the forums on my new site, it doesn't break the % based div/table for the content. 我正在尝试获取它,以便在我的新网站的论坛中输入一长串字符时,不会破坏基于%的div /表的内容。

This is what I mean 这就是我的意思

What am I doing wrong? 我究竟做错了什么? How do I make it so that it strictly breaks the long character, to fit the area no matter what. 我如何做到这一点,以使其严格打破长字符,无论如何都适合该区域。 I even tried using php code, however it didn't much work as I wanted it to: 我什至尝试使用php代码,但是并没有太多的工作,因为我想要它:

 <?php echo wordwrap($Body),150,"\n",true); ?>

Any ideas, I made that codepen link myself with an example of what happens, and how I want it to look. 任何想法,我都会让Codepen将自己与发生的事以及我希望它的外观的示例联系起来。

You can add some CSS: 您可以添加一些CSS:

.innerdiv{
  width: 100%; 
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;

}

Adding the word-break: and hyphens: properties will force the long word to break rather than extending it's container. 添加word-break:hyphens:属性将迫使长单词断开而不是扩展其容器。

jsFiddle demo. jsFiddle演示。

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

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