用 CSS 打断长字 [英] Break long word with CSS

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

问题描述

我遇到过这样的情况,其中可能有像hellowordsometext"这样的长单词或像1234567891122"这样的整数,中间没有任何空格.请检查这个js.http://jsfiddle.net/rzq5e/6/

在达到 div 宽度后如何将其分成下一行.现在发生的是,它与 div 一起展开

Solutionforentprise

解决方案

你需要的是word-wrap: break-word;,这个属性会强制非间隔字符串在<代码>div

演示

div {宽度:20px;自动换行:断字;}

I have a situation where there can be long words like 'hellowordsometext' or integer like '1234567891122' without any space in between. check this js please. http://jsfiddle.net/rzq5e/6/

how is it possible to break it in to next line after it reach the div width. what happens now is, it spans out out along with th div

<div>Solutionforentprise</div>

解决方案

What you need is word-wrap: break-word;, this property will force the non spaced string to break inside the div

Demo

div {
   width: 20px;
   word-wrap: break-word;
}

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

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