文本没有包装在div元素中

Vas*_*lis 41 css htmltext word-wrap

我遇到了一个以前从未发生过的问题,看起来真的是史无前例的,有些文字并没有包含在div中.

在这个链接中是我的HTML代码示例:

http://jsfiddle.net/NDND2/2/

<div id="calendar_container">
   <div id="events_container">  
      <div class="event_block">
         <div class="title">
            lorem ipsum lorem ipsumlorem ipsumlorem ipsumlorem
         </div>
      </div>
   </div>
</div>
Run Code Online (Sandbox Code Playgroud)

任何帮助?

小智 65

我发现这有助于我的话在WooThemes Testimonial插件中突破了这个词.

.testimonials-text {
    white-space: normal;
}
Run Code Online (Sandbox Code Playgroud)

在这里玩它http://nortronics.com.au/recomendations/

<blockquote class="testimonials-text" itemprop="reviewBody">

<a href="http://www.jacobs.com/" class="avatar-link">

<img width="100" height="100" src="http://nortronics.com.au/wp-content/uploads/2015/11/SKM-100x100.jpg" class="avatar wp-post-image" alt="SKM Sinclair Knight Merz">

</a>
<p>Tim continues to provide high-level technical applications advice and support for a very challenging IP video application. He has shown he will go the extra mile to ensure all avenues are explored to identify an innovative and practical solution.<br>Tim manages to do this with a very helpful and professional attitude which is much appreciated.
</p>
</blockquote>
Run Code Online (Sandbox Code Playgroud)


j08*_*691 54

那是因为那个长字符串中没有空格所以它必须从容器中分离出来.添加word-break:break-all;到.title规则以强制休息.

#calendar_container > #events_container > .event_block > .title {
    width:400px;
    font-size:12px;
    word-break:break-all;
}
Run Code Online (Sandbox Code Playgroud)

jsFiddle例子


fri*_*der 6

你可以添加这一行:word-break:break-all;你的CSS代码


Fak*_*eer 6

这可能会帮助一小部分人仍然摸不着头脑。从剪贴板复制到 VSCode 的文本可能有一个不可见的硬空格字符,防止换行。使用 HTML 检查器检查它

带有硬空格的字符串


Mat*_*ell 5

jsfiddle中的问题是您的伪文本全是一个单词。如果您使用问题中给出的lorem ipsum,则文本会自动换行。

如果您想将大单词分解为中间单词并环绕,请将其添加到您的.title CSS中:

word-wrap: break-word;
Run Code Online (Sandbox Code Playgroud)