六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 48|回复: 0

控制DIV内容换行CSS样式

[复制链接]

升级  16.33%

75

主题

75

主题

75

主题

举人

Rank: 3Rank: 3

积分
249
 楼主| 发表于 2013-2-7 15:01:16 | 显示全部楼层 |阅读模式
    利用 CSS 控制 DIV 块中内容强制换行。先来看下示例:
 
一、未加CSS控制情况:
<div style="width:30%;"><!--数字串-->186608752,186608932,186610076,186600607,186576340,186576338,186610806,186610424,186586705,22833794,150555535,150634343,153999301,186610076,186600607,186576340,186576338,186610806,186610424,186586705,22833794,150555535,150634343,153999301<br/><br/><!--英文串-->break-all Behaves the same as normal for Asian text, yet allows the line to break arbitrarily for non-Asian text.This value is suited to Asian text that contains some excerpts of non-Asian text.keep-all Does not allow word breaking for Chinese, Japanese, and Korean. Functions the same way as normal for all non-Asian languages. This value is optimized for text that includes small amounts of Chinese, Japanese, or Korean.<br/><br/><!--中英文混排串-->测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content</div> 页面显示效果如下:

二、加CSS控制情况:
<div style="width:30%;word-wrap:break-word;overflow:hidden;"><!--数字串-->186608752,186608932,186610076,186600607,186576340,186576338,186610806,186610424,186586705,22833794,150555535,150634343,153999301,186610076,186600607,186576340,186576338,186610806,186610424,186586705,22833794,150555535,150634343,153999301<br/><br/><!--英文串-->break-all Behaves the same as normal for Asian text, yet allows the line to break arbitrarily for non-Asian text.This value is suited to Asian text that contains some excerpts of non-Asian text.keep-all Does not allow word breaking for Chinese, Japanese, and Korean. Functions the same way as normal for all non-Asian languages. This value is optimized for text that includes small amounts of Chinese, Japanese, or Korean.<br/><br/><!--中英文混排串-->测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content,测试内容,test,content</div> 显示效果如下:

 
CSS:word-wrap:break-word;overflow:hidden;
 
word-wrap:控制换行,当break-word时,是强制换行;
与 break-word 不同,是控制是否断词的。
 
overflow 属性规定当内容溢出元素框时发生的事情,当 hidden时,内容会被修剪,并且其余内容是不可见的。
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表