CSS 如何在 Span 中打破长字?(使用 Twitter Bootstrap)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17124827/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 23:13:56  来源:igfitidea点击:

how to break long word in Span?(using Twitter Bootstrap)

css

提问by ePezhman

I'm using Twitter bootstrap in my site and I'm having span which may contain long word and I need to break it. I use this Css but not working? what's problem?

我在我的网站中使用 Twitter 引导程序,并且我的跨度可能包含长词,我需要打破它。我使用这个 Css 但不起作用?什么问题?

.fidDivComment {
    white-space: pre-wrap;
    display: inline-block;
}

enter image description here

在此处输入图片说明

回答by Adam Simpson

You need to add this to your CSS for that span

您需要将其添加到该跨度的 CSS 中

span {
  -ms-word-break: break-all;
  word-break: break-all;

  /* Non standard for webkit */
  word-break: break-word;

  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  hyphens: auto;
}

See this articlefor an explanation.

请参阅此文章以获取解释。

回答by Mina Luke

The questions stated this:

这些问题说明了这一点:

(using Twitter Bootstrap)

(使用 Twitter Bootstrap)

so the bootstrap fix is this: @include hyphens;this bootstrap out of the box mixin will add word-wrap: break-word;this mixin is exist under this path:

所以引导程序修复是这样的:@include hyphens;这个引导程序开箱即用的mixin将添加 word-wrap: break-word;这个mixin存在于这个路径下:

/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_vendor-prefixes.scss