我想保留我的段落,所以我将该代码放在 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/