如何使用 CSS 使 Firefox 断字?

发布于 2024-10-05 06:12:48 字数 313 浏览 4 评论 0原文

到目前为止,这是我的代码:

<div style="width:100px;height:100px;background:red">
            ssssssssssssssssssssssssssssssssssssss
</div>

但是,事实

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

证明没有用,因为它无法在 Firefox 上自动换行。 使用 CSS 我能做什么

This is my code so far:

<div style="width:100px;height:100px;background:red">
            ssssssssssssssssssssssssssssssssssssss
</div>

However,

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

does not prove useful, since it can't word-wrap on Firefox.
What can I do, using CSS?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

绝不服输 2024-10-12 06:12:49
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+ */
width:200px;

上面的代码对我来说非常有用

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+ */
width:200px;

The above piece of code works for me wonderfully

如梦初醒的夏天 2024-10-12 06:12:49

一起使用以下规则:

/* For Firefox */
white-space: pre-wrap;
word-break: break-all;

/* For Chrome and IE */
word-wrap: break-word;

Use the following rules together:

/* For Firefox */
white-space: pre-wrap;
word-break: break-all;

/* For Chrome and IE */
word-wrap: break-word;
韬韬不绝 2024-10-12 06:12:49

您必须在 div 上应用以下 css 类:

.content-div{
    word-break:break-all;
    word-wrap: break-word;
}

并在 div 中绑定的表格上添加以下样式

style='table-layout:fixed;width:306px;'

它适用于 IE7、FF 3.6 和 Chrome。

You have to apply the below css class on div:

.content-div{
    word-break:break-all;
    word-wrap: break-word;
}

And add below style on table which is bind in div

style='table-layout:fixed;width:306px;'

It will work on IE7, FF 3.6 and Chrome.

神经暖 2024-10-12 06:12:49

您将宽度和显示属性与自动换行属性一起使用:

width: 100px;
word-wrap: break-word;
display:inline-block;

它在 IE 和 FF 中都适用于我。

you use width and display properties together with word-wrap property:

width: 100px;
word-wrap: break-word;
display:inline-block;

It works for me both in IE and in FF.

谁把谁当真 2024-10-12 06:12:49

对于 Firefox,它的工作方式如下:

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

it works this way for Firefox:

word-break: initial;
word-wrap: break-word;
梦太阳 2024-10-12 06:12:49

这对我来说很好用:

/* For Firefox */
white-space: pre-wrap;
overflow-wrap: break-word;

/* For Chrome and IE */
word-wrap: break-word;

看起来溢出换行是 Firefox 中的新功能。
更多信息可以在这里找到:

https://developer.mozilla。 org/en-US/docs/Web/CSS/overflow-wrap

That work for me nicely:

/* For Firefox */
white-space: pre-wrap;
overflow-wrap: break-word;

/* For Chrome and IE */
word-wrap: break-word;

It looks overflow-wrap is something new in firefox.
More info can be found here:

https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap

听你说爱我 2024-10-12 06:12:49

我们试试这个怎么样:

div{ overflow-wrap:break-word; }

Hows about we try this:

div{ overflow-wrap:break-word; }
风渺 2024-10-12 06:12:49

我需要几个答案的组合才能让它在 Chrome 和 Firefox 中工作:

.white-space-pre-wrap {
  white-space: pre-wrap;
  word-break: break-all;
  word-wrap: break-word;
  display: inline-block;
}

I needed a combination of several answers to get it to work in both Chrome and Firefox for me:

.white-space-pre-wrap {
  white-space: pre-wrap;
  word-break: break-all;
  word-wrap: break-word;
  display: inline-block;
}
倒带 2024-10-12 06:12:49

word-break:break-word 已弃用。你应该使用:
断字:正常;溢出换行:任何地方

word-break: break-word is deprecated. You should use:
word-break: normal; overflow-wrap: anywhere

携君以终年 2024-10-12 06:12:49

它对我来说效果很好:

  /* Mozilla fix */
  word-break: break-all;

  /* Chrome fix */
  word-break: break-word;
  word-wrap: break-word;
  overflow-wrap: break-word;

It works fine for me:

  /* Mozilla fix */
  word-break: break-all;

  /* Chrome fix */
  word-break: break-word;
  word-wrap: break-word;
  overflow-wrap: break-word;
甜是你 2024-10-12 06:12:49

使用下面的样式,它在 mozilla firefox 中对我来说效果很好。

word-wrap: break-word;
display:block;

Use the below styles it worked fine for me in mozilla firefox.

word-wrap: break-word;
display:block;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文