CSS word-wrap同word-break的区别

2020-05-08 08:48:30易采站长站整理

  1.htm
  <style>
  .c1{ width:300px;  border:1px solid red}
  .c2{ width:300px;word-wrap:break-word;  border:1px solid yellow}
  .c3{ width:300px;word-wrap:break-word;word-break:break-all;  border:1px solid green}
  .c4{ width:300px;word-wrap:break-word;word-break:keep-all; border:1px solid blue}
  .c5{ width:300px;word-break:break-all;  border:1px solid black}
  .c6{ width:300px;word-break:keep-all;  border:1px solid red}
  .c7{ width:300px;word-wrap:break-word;overflow:auto;  border:1px solid yellow}
  </style>
  .c1{ width:300px;  border:1px solid red}
  <div class="c1">asdasd
</div>
  <div class=c1>
  This is all English. This is all English. This is all English.
  </div>
  <div class=c1>
  全是中文的情况。全是中文的情况。全是中文的情况。
  </div>
  <div class=c1>
  中英文混排的情况。Chinese and English. 中英文混排的情况。Chinese and English.
  </div>
  <br>
  .c2{ width:300px;word-wrap:break-word; border:1px solid yellow}
  <div class="c2">
  safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
  </div>
  <div class=c2>
  This is all English. This is all English. This is all English.
  </div>
  <div class=c2>
  全是中文的情况。全是中文的情况。全是中文的情况。
  </div>
  <div class=c2>
  中英文混排的情况。Chinese and English. 中英文混排的情况。Chinese and English.
  </div>
  <br>
  .c3{ width:300px;word-wrap:break-word;word-break:break-all;  border:1px solid green}
  <div class="c3">
  safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
  </div>
  <div class=c3>
  This is all English. This is all English. This is all English.
  </div>
  <div class=c3>
  全是中文的情况。全是中文的情况。全是中文的情况。
  </div>
  <div class=c3>
  中英文混排的情况。Chinese and English. 中英文混排的情况。Chinese and English.
  </div>
  <br>
  .c4{ width:300px;word-wrap:break-word;word-break:keep-all; border:1px solid blue}
  <div class="c4">
  safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
  </div>
  <div class=c4>
  This is all English. This is all English. This is all English.
  </div>
  <div class=c4>
  全是中文的情况。全是中文的情况。全是中文的情况。