简体   繁体   English

CSS断字在Div中不起作用

[英]CSS break-word Not working in a Div

I am iterating words from the db using ionic framework. 我正在使用离子框架迭代数据库中的单词。 The words spans across the div and never brakes on encountering the end of the div and instead the words truncates. 这些单词跨过div,并且在遇到div的结尾时不会刹车,而是将其截断。 I have applied break-word to my css but no good result achieved. 我对CSS应用了断行词,但未取得良好结果。

app.js file that returns the parent div: 返回父div的app.js文件:

$scope.isNotCurrentUserInner = function(user){

            if(current_user != user){
                return 'other_messages';
            }
            return 'messages';
        };

This is my css 这是我的CSS

.messages {
  background: #c2dfff;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);

}
.messages div {
  font-size: 14.5px;
  font-family: "Helvetica Neue";
  margin: 0 0 0.2rem 0;
  color: #000;
  word-wrap: break-word;
}

This is the display words 这是显示字

<li class="{{ isNotCurrentUserInner(msg.Name) }}">
    <div>{{ msg.Content }}</div>
</li>

This is the screen copy: 这是屏幕副本: 在此处输入图片说明 kindly assist! 请协助!

Your div does not have the class "messages" add that class and change ".messages div" to just ".messages". 您的div没有将“ messages”添加到该类,并将“ .messages div”更改为“ .messages”。

\n

If that doesn't help, try changing 如果这样做没有帮助,请 尝试更改

"word-wrap: break-word;" “自动换行:断行;” to "word-break: break-all;" 改为“断词:全部”;

Reproducing what you've described in your question works exactly as you're expecting. 复制您在问题中描述的内容完全符合您的期望。 You need to provide more information or a live example of your issue: 您需要提供更多信息或问题的实时示例:

https://jsfiddle.net/jabark/pg0czu9L/ https://jsfiddle.net/jabark/pg0czu9L/

 .messages { background: #c2dfff; padding: 10px; border-radius: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); } .messages div { font-size: 14.5px; font-family: "Helvetica Neue"; margin: 0 0 0.2rem 0; color: #000; word-wrap: break-word; } 
 <div class="messages"> <div>Helllooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo</div> </div> 

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

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