微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – 如何模仿分词:破解词;适用于IE9,IE11和Firefox

如何模仿断言:断言;对于IE9,IE11和Firefox?

它似乎适用于Chrome.我已经了解并理解它只是一个非标准的webkit.

仅供参考,我尝试过使用,

white-space: pre-wrap;

而更像是,

overflow-wrap: break-word;

还尝试了下面提到的CSS,

word-wrap:  break-word;
 word-break: break-word;

但这些似乎不起作用.

I can’t provide fixed width to the span(which contains the text) by making it display: block; explicitly as the text is dynamic and will differ according to the user’s Geo-location. Currently we support around 18 languages.

这是代码的外观,

HTML,

<div id="grid2">
     <span id="theSpan">Product Support</span>
</div>

CSS,

#theSpan{
   white-space: pre-wrap;      /* CSS3 */   
   white-space: -moz-pre-wrap; /* Firefox */    
   white-space: -pre-wrap;     /* Opera 7 */   
   white-space: -o-pre-wrap;   /* Opera 7 */    
   word-wrap: break-word;      /* IE */
   word-break: break-all;
}

#grid2{
   width: 100px;
}

看起来像这样,

我希望它像,

请注意:
我不得不使用word-break:break-all;至于某些语言,翻译后的文本太长而且溢出了网格. “产品支持”一词是动态的.

更新:
我有一个固定宽度的div,id为grid2.在其中一种语言中,翻译的文本太长,它是一个单词,它流出grid2 div.

也更新了代码.

解决方法

我在Chrome,Firefox和IE上取得了很好的成功,仅使用:
word-break: break-word;
word-wrap: break-word;

在我的问题情况下,我已经在使用:

display: table-cell;

我最终不得不包括在内

max-width: 440px;

在所有浏览器中包装.在大多数情况下,最大宽度不是必需的.

原文地址:https://www.jb51.cc/html/227789.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐