CSS行包装 [英] CSS line wrapping

查看:150
本文介绍了CSS行包装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个块容器

<div>
 this is a very long string which contains a bunch of characters that I want to break at container edges.
</div>

有任何css属性,我可以设置强制它达到容器宽度时,的字符串内容,例如:

are there any css properties I can set to force it to break when it reaches the container width, regardless of the contents of the string, for example a break like:

this is a ve
ry long stri
ng which ...

是我想要的。现在,它似乎总是喜欢打破空格字符或其他特殊字符(如/).

is pretty much what I want. Right now, it seems to always prefer to break at whitespace characters or other special characters (such as /).

推荐答案

CSS3属性调用 word-break ,可能会对您有所帮助。

There's a CSS3 property called word-break that may be of some use to you in future.

http://www.css3.com/css-word-break/

break-all 值看起来符合您的要求:

The break-all value looks to do the thing you're asking for:


在内容包含大多数亚洲字符集内容时有用,此值的行为类似于正常。

Useful where content contains a majority of Asian character set content, to which this value behaves like ‘normal’. Non-Asian character set content may be arbitrarily broken across lines.

对于更受支持的CSS版本,我不相信一种方法可以做到这一点。

As for more supported versions of CSS, I don't believe there's a way you can do this.

这篇关于CSS行包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆