<strike id="3tkic"><sup id="3tkic"></sup></strike>

  1. <ul id="3tkic"></ul>
      <b id="3tkic"><legend id="3tkic"></legend></b>
      <b id="3tkic"><meter id="3tkic"></meter></b>

    • <strike id="3tkic"></strike>

      <blockquote id="3tkic"></blockquote>

    • 亚洲AV无码国产在丝袜线观看_亚洲第一页A∨在线_亚洲国产人成在线观看69网站_无码日韩人妻AV一区免费l

      css控制文字自動換行

      2016/10/15 8:31:45   閱讀:1783    發(fā)布者:1783

      自動換行問題,正常字符的換行是比較合理的,而連續(xù)的數(shù)字和英文字符常常將容器撐大,挺讓人頭疼,下面介紹的是CSS如何實(shí)現(xiàn)換

      行的方法

      對于div,p等塊級元素
      正常文字的換行(亞洲文字和非亞洲文字)元素?fù)碛心J(rèn)的white-space:normal,當(dāng)定義的寬度之后自動換行

      html

      正常文字的換行(亞洲文字和非亞洲文字)元素?fù)碛心J(rèn)的white-space:normal,當(dāng)定義

      css
      #wrap{white-space:normal; width:200px; }

      1.(IE瀏覽器)連續(xù)的英文字符和阿拉伯?dāng)?shù)字,使用word-wrap : break-word ;
      或者word-break:break-all;實(shí)現(xiàn)強(qiáng)制斷行 #wrap{word-break:break-all; width:200px;}

      或者
      #wrap{word-wrap:break-word; width:200px;}

      abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111

      效果:可以實(shí)現(xiàn)換行

      2.(Firefox瀏覽器)連續(xù)的英文字符和阿拉伯?dāng)?shù)字的斷行,Firefox的所有版本的沒有
      解決這個(gè)問題, 我們只有讓超出邊界的字符隱藏或者,給容器添加滾動條

      #wrap

      {word-break:break-all; width:200px; overflow:auto;}

      abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111

      效果:容器正常,內(nèi)容隱藏

      對于table

      1. (IE瀏覽器)使用 table-layout:fixed;強(qiáng)制table的寬度,多余內(nèi)容隱藏

      <table style="table-layout:fixed" width="200"> 
      <tr> 
      <td>abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss 
      </td> 
      </tr> 
      </table>

      效果:隱藏多余內(nèi)容

      2.(IE瀏覽器)使用 table-layout:fixed;強(qiáng)制table的寬度,
      內(nèi)層td,th采用word-break : break-all;或者word-wrap : break-word ;換行

       

      <table width="200" style="table-layout:fixed;"> <tr> 
      <td width="25%" style="word-break : break-all; ">abcdefghigklmnopqrstuvwxyz 1234567890  
      </td> <td style="word-wrap : break-word ;">abcdefghigklmnopqrstuvwxyz 1234567890 </td>
      </tr> </table>

       

      效果:可以換行

      3. (IE瀏覽器)在td,th中嵌套div,p等采用上面提到的div,p的換行方法

      4.(Firefox瀏覽器)使用 table-layout:fixed;強(qiáng)制table的寬度,內(nèi)層td,th采
      用word-break : break-all;或者word-wrap : break-word ;換行,
      使用overflow:hidden;隱藏超出內(nèi)容,這里overflow:auto;無法起作用

      <table style="table-layout:fixed" width="200"> 
      <tr> 
      <td width="25%"  style="word-break : break-all; overflow:hidden; "> 
      abcdefghigklmnopqrstuvwxyz1234567890</td> 
      <td width="75%" style="word-wrap : break-word; overflow:hidden; "> 
      abcdefghigklmnopqrstuvwxyz1234567890</td> 
      </tr> 
      </table>

      效果:隱藏多于內(nèi)容

      5.(Firefox瀏覽器) 在td,th中嵌套div,p等采用上面提到的對付Firefox的方法
      運(yùn)行代碼框100素材網(wǎng)
      最后,這種現(xiàn)象出現(xiàn)的幾率很小,但是不能排除網(wǎng)友的惡搞。如果

      有什么問題請到在下面留言

      下面是提到的例子的效果

        
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
      <html xmlns="http://www.w3.org/1999/xhtml"> 
      <head> 
      <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
      <title>字符換行 
        
      </title> 
      <style type="text/css"> 
      table,td,th,div { border:1px green solid;} 
      code { font-family:"Courier New", Courier, monospace;} 
        
      </style> 
      </head> 
      <body> 
      <h1><code>div</code></h1> 
      <h1><code>All white-space:normal;</code></h1> 
      <div style="white-space:normal; width:200px;">Wordwrap still occurs in a td element that  
      has its WIDTH attribute set to a value smaller than the unwrapped content of the cell,  
      even if the noWrap property is set to true. Therefore, the WIDTH attribute takes  
      precedence over the noWrap property in this scenario</div> 
        
      <h1><code>IE  word-wrap : break-word ;</code></h1> 
      <div style="word-wrap : break-word ; width:200px;"> 
      abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div> 
      <h1><code>IE  word-break:break-all;</code></h1> 
      <div style="word-break:break-all;width:200px;"> 
      abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div> 
        
      <h1><code>Firefox/ word-break:break-all; overflow:auto;</code></h1> 
      <div style="word-break:break-all; width:200px; overflow:auto;"> 
      abcdefghijklmnabcdefghijklmnabcdefghijkl 
      mn111111111</div> 
      <h1><code>table</code></h1> 
      <h1><code>table-layout:fixed;</code></h1> 
      <table style="table-layout:fixed" width="200"> 
      <tr> 
      <td>abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss</td> 
      </tr> 
      </table> 
      <h1><code>table-layout:fixed; word-break : break-all; word-wrap :  
      break-word ;</code></h1> 
      <table width="200" style="table-layout:fixed;"> 
      <tr> 
      <td width="25%" style="word-break : break-all; "> 
      abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss</td> 
      <td style="word-wrap : break-word ;">abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss</td> 
      </tr> 
      </table> 
      <h1><code>FF  table-layout:fixed; overflow:hidden;</code></h1> 
      <table style="table-layout:fixed" width="200"> 
      <tr> 
      <td width="25%"  style="word-break : break-all; overflow:hidden; "> 
      abcdefghigklmnopqrstuvwxyz1234567890</td> 
      <td width="75%" style="word-wrap : break-word; overflow:hidden; "> 
      abcdefghigklmnopqrstuvwxyz1234567890</td> 
      </tr> 
      </table> 
      </body> 
      </html>
      亚洲AV无码国产在丝袜线观看_亚洲第一页A∨在线_亚洲国产人成在线观看69网站_无码日韩人妻AV一区免费l
      <strike id="3tkic"><sup id="3tkic"></sup></strike>

      1. <ul id="3tkic"></ul>
          <b id="3tkic"><legend id="3tkic"></legend></b>
          <b id="3tkic"><meter id="3tkic"></meter></b>

        • <strike id="3tkic"></strike>

          <blockquote id="3tkic"></blockquote>

        • 滕州市| 郯城县| 太湖县| 离岛区| 含山县| 长白| 宁德市| 纳雍县| 手游| 梅河口市| 康马县| 开平市| 杨浦区| 湘乡市| 天祝| 海晏县| 五家渠市| 镇巴县| 木里| 洛隆县| 伊春市| 奈曼旗| 淅川县| 上栗县| 淅川县| 当雄县| 吴川市| 赤壁市| 五华县| 连云港市| 偏关县| 象州县| 吴堡县| 菏泽市| 金溪县| 临汾市| 江川县| 淮南市| 灌阳县| 区。| 乌拉特中旗|