控制DIV内容换行CSS样式

    利用 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时,内容会被修剪,并且其余内容是不可见的。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值