简体   繁体   English

div 中的段落没有使用 CSS 打破单词

[英]Paragraph in div is not breaking word using CSS

Problem:问题:

在此处输入图片说明

Check Here, Sample Page With CSS Problem and here is a VIDEO to explain the problem检查这里,带有 CSS 问题的示例页面,这里有一个视频来解释这个问题

Details Of Problem:问题详情:

Am using ckeditor to fill my content, but looks that word wrapping is conflicting with WYSIWYG from CKEditor ...我正在使用ckeditor来填充我的内容,但看起来自动换行与来自CKEditor 的WYSIWYG 相冲突......

If I put in CKEditor long line, I expect it gets word-wrapped smoothly.如果我放入CKEditor长行,我希望它能够顺利换行。

But what I have is random break-word works on 95% of my cases!但是我所拥有的是随机断词适用于我 95% 的情况!

What I Tried:我试过的:

I tried and researched but each time there is a case where it just won't work for some scenarios!.我尝试并研究过,但每次都有一种情况,它在某些情况下不起作用!。

stackoverflow break-word question stackoverflow断字问题

CSS tricks and tips CSS 技巧和窍门

Can this be a browser problem or?这可能是浏览器问题还是?

@shareef you need to remove all &nbsp then you need to use word-break: break-word; @shareef 你需要删除所有&nbsp然后你需要使用word-break: break-word; in your p tag在你的p标签中

Paste this script anywhere on your page.将此脚本粘贴到页面上的任何位置。 It will manually remove all the  它将手动删除所有  characters found in all elements inside the .event-text container and replaces them with spaces..event-text容器内的所有元素中找到的字符,并用空格替换它们。

window.addEventListener('DOMContentLoaded', () => {
    const texts = document.querySelectorAll('.event-text *');
    texts.forEach(text => text.innerText = text.innerText.replace(/\u00a0/g, ' '));
});

This is a hack, not a permanent solution.这是一个黑客,而不是一个永久的解决方案。 I strongly advise you to contact the folks at CKEditor and ask them for a fix.我强烈建议您联系 CKEditor 的人员并要求他们进行修复。

For more detailed other options with CKEditor configuration, ckeditor unwanted nbsp characters you may check有关 CKEditor 配置的更详细的其他选项,您可以检查ckeditor 不需要的 nbsp 字符

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

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