【问题标题】:Break word on IE, EDGE and firefox not workingIE、EDGE 和 firefox 无法正常工作
【发布时间】:2020-08-12 23:47:06
【问题描述】:

edge 不支持 word-break:break-word,ie 和 firefox。 如果空间存在,我需要css来打破这个空间,但如果空间不存在,直接打破这个词(检查chrome或safari中的小提琴)。 由于 MS edge 、IE 和 Firefox 不支持断词,我不得不使用 break-all 但即使句子中存在空格,它也会在中间断词。

这里有什么可以用的css

这是文本在不同浏览器上尝试的小提琴,你会得到我遇到的问题

https://jsfiddle.net/emx9bL3y/7/

@supports (-ms-ime-align:auto) {
.white-space-pre-wrap{
word-wrap:break-word!important;
word-break:break-all!important;
display:inline-block; 
}
 }

谢谢

解决方案 Breaking words using CSS 声明标签应具有固定宽度,但在这种情况下,标签的宽度会有所不同,它可以是屏幕宽度的 200 像素。因此,如果屏幕尺寸越大,标签的宽度就会越大,反之亦然。

【问题讨论】:

  • Breaking words using CSS的可能重复
  • TylerH 我无法为我的解决方案添加宽度,因为我的文本标签的宽度会有所不同。在这种情况下不能给出固定宽度

标签: css internet-explorer microsoft-edge word-break


【解决方案1】:

请检查此代码,它正在工作。

.word-breck {
    width: 100%;
    border: solid 1px #ccc;
    word-wrap: break-word;
}
<div class="word-breck">    <p>Itisalongestablishedfactthatareaderwillbedistractedbythereadablecontentofapagewhenlookingatitslayout.ThepointofusingLoremIpsumisthatithasamore-or-lessnormal.</p>
</div>

【讨论】:

  • 它仅适用于 chrome 和 safari,不适用于其他浏览器。需要修复 edge,ie 和 firefox,因为它们不支持 break-word 属性
猜你喜欢
  • 1970-01-01
  • 2017-12-27
  • 1970-01-01
  • 2019-01-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-11
相关资源
最近更新 更多