码迷,mamicode.com
首页 > Web开发 > 详细

CSS3----word-wrap(单词换行)

时间:2017-07-26 14:44:18      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:type   css   超出   set   height   换行   总结   自动   ref   

 

代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
  <title></title>
   <style type="text/css">
       .head{
          margin: 0 0 0 100px;
       }
       .container{
         margin: 0 0 0 100px;
       }
       .container div{
        width: 230px;
        height: 200px;
        border: 1px solid red;
        padding: 20px;
       }
       .d{

       }
       .d1{
        word-wrap: normal;
       }
       .d2{
        word-wrap: break-word;
       }
   </style>
</head>
<body>
    <div class="head">
      <h1>word-wrap 文本换行</h1>
      <h2>首页<a href="index.html"></a></h2>
    </div>
    <div class="container">
         <h2>默认normal</h2>
        <div class = ‘d‘>
         阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺
         sunlikesunlikesunlikesunlikesunlikesunlikesunlikesunlike
         sunlike sunlike sunlike sunlike sunlike sunlike sunlike sunlike 
         </div> 
         <h2>word-wrap: normal;</h2>
         <div class = ‘d1‘>
         阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺
         sunlikesunlikesunlikesunlikesunlikesunlikesunlikesunlike
          sunlike sunlike sunlike sunlike sunlike sunlike sunlike sunlike 
         </div> 
          <h2>word-wrap: break-word;</h2>
          <div class = ‘d2‘>
         阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺阿理旺旺
         sunlikesunlikesunlikesunlikesunlikesunlikesunlikesunlike
          sunlike sunlike sunlike sunlike sunlike sunlike sunlike sunlike 
         </div> 
    </div>
</body>
</html>

  

 

 

效果1:

技术分享

 

总结1:默认情况下,word-wrap的值为normal,中文字符自动换行,英文单词不断行

 

 

效果2:

技术分享

 

总结2:设置word-wrap的值为normal时,中文字符自动换行,英文单词不会截断来换行,超出本分直接溢出

 

 

效果3:

技术分享

 

 

总结3:设置word-wrap值为break-word时,中文自动换行,英文单词或字符截断换行

 

CSS3----word-wrap(单词换行)

标签:type   css   超出   set   height   换行   总结   自动   ref   

原文地址:http://www.cnblogs.com/SunlikeLWL/p/7239202.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!