html - 添加空白 pre 后文本在 bootstrap 中超出 div

标签 html css

我有一个 div,它将显示来自多行文本字段的内容

<div class="col-sm-12">
      <span class="description ng-binding">
         Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
         Nam porttitor varius tortor..
      </span>           
</div>

描述div有时需要显示多行文字。但它在一行中显示内容而忽略了下一行(新)。所以我添加了下面的 css

.description {
    white-space: pre;
}

添加后,显示为多行。但现在的问题是,如果该行很大,那么它会超出父 div 而不会包含在 div 中。

我尝试按照建议添加以下 css here , 但它没有用

.description {
    white-space: pre;
    max-width: 98%;
    text-overflow: ellipsis;
    word-break: break-word;
}

enter image description here

我错过了什么?

最佳答案

我将 css 从 white-space:pre 更改为 white-space:pre-wrap 并且有效

.description{
    white-space: pre;
}

关于html - 添加空白 pre 后文本在 bootstrap 中超出 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52724291/

相关文章:

javascript - 更改背景 onclick 两次

php - 可能危险的文本输入处理

html - 使用 CSS 动画交换位置

html - 如何确保 DIV 中的图像随浏览器调整大小而调整大小

html - CSS 不透明度在这种情况下不起作用

css - 如何从弹出窗口中删除背景控件?

css - 考虑屏幕尺寸显示Django网站

javascript - 如何在 anchor 标记内设置跨度值

javascript - 确定给定点js的所有元素

html - 如何用CSS移动小部件?