html - 在 html 标签中,单词被打破

标签 html css

我想保留我的段落,所以我将该代码放在 pre 标记中,但在那之后我的话就断了。有没有解决这个问题的方法。我不想食言,我还提供了 div 宽度。下面是我的代码:

<li class="list-group-item" ng-repeat = "answer in answers">

                    <span class="label label-default label-pill pull-xs-right " style="float: right">{{answer.UserID}}</span><br>
                    <pre style="font-family: helvetica;font-size: 14px;display: block;line-height: 20px;text-align: left "> {{answer.AnswerStr }} </pre>

            </li>

最佳答案

查看 Chris Coyier 的博客文章:Make "Pre" Text Wrap

简而言之,将其添加到您的 CSS 文件中:

/* Browser specific (not valid) styles to make preformatted text wrap */        

pre {
 white-space: pre-wrap;       /* css-3 */
 white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
 white-space: -pre-wrap;      /* Opera 4-6 */
 white-space: -o-pre-wrap;    /* Opera 7 */
 word-wrap: break-word;       /* Internet Explorer 5.5+ */
}

关于html - 在 html 标签中,单词被打破,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34612833/

相关文章:

html - HTML5的视频标签(默认图片)

HTML 5 具有重复数字的有序列表

html - 如何使用表格在行上添加边框?

javascript - 无法让 "Draggable"工作

jquery - 如何让我的特定菜单使事件元素具有不同的颜色

javascript - 在全屏视频上显示文字

html - 定位元素和调整网页宽度的问题

html - 在CSS中彼此相邻显示新闻

html - 如何使颜色输入在浏览器之间显示一致的最小宽度?

css - 如何使 <li> 元素宽度适合文本长度?