简体   繁体   English

用CSS打破常规?

[英]Break word with CSS?

I work with a web site and i have many long word in my menu. 我在一个网站上工作,菜单上有很多字。 I would like to display them in two line but not one. 我想将它们显示为两行而不是一行。 I used word-wrap proprety in CSS. 我在CSS中使用了自动换行功能。

{word-wrap: break-word}

But this property breaks the word. 但是,此属性无法实现。

For example I have : Solution for enterprise 例如,我有: Solution for enterprise

When I use the word-wrap property I get this : 当我使用自动换行属性时,我得到了:

Solution for enter
prise

Whereas I would like to have: 而我希望拥有:

Solution
for enterprise

Thanks 谢谢

Various options, some mentioned in the comments: 各种选项,其中一些在注释中提到:

  • set a width on the link wrapper ( li or whatever) so that the words naturally wrap; 在链接包装上设置宽度( li或其他),以便单词自然地包装;
  • add a <br> element where you want the words to wrap; 在您希望文字换行的位置添加<br>元素;
  • wrap a span around the word(s) to wrap and set the span to display: block . span环绕在要包装的单词周围,并将范围设置为display: block

请改用CSS的空白属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM