資料整理

           

          CSS的自動換行

          大家都知道連續的英文或數字能是容器被撐大,不能根據容器的大小自動換行,下面是 CSS如何將他們換行的方法!

          對于div

          1.(IE瀏覽器)white-space:normal; word-break:break-all;這里前者是遵循標準。


          #wrap{white-space:normal; width:200px; }
          或者
          #wrap{word-break:break-all;width:200px;}

          eg.
          <div id="wrap">ddd1111111111111111111111111111111111</div>


          效果:可以實現換行
          2.(Firefox瀏覽器)white-space:normal; word-break:break-all;overflow:hidden;同樣的FF下也沒有很好的實現方法,只能隱藏或者加滾動條,當然不加滾動條效果更好!


          #wrap{white-space:normal; width:200px; overflow:auto;}
          或者
          #wrap{word-break:break-all;width:200px; overflow:auto; }

          eg.

          <div id="wrap">ddd1111111111111111111111111111111111111111</div>

          效果:容器正常,內容隱藏
          對于table

          1. (IE瀏覽器)使用樣式table-layout:fixed;
          eg.


          <style>
          .tb{table-layout:fixed}
          </style>

          <table class="tbl" width="80">
          <tr>
          <td>abcdefghigklmnopqrstuvwxyz 1234567890
          </td>
          </tr>
          </table>


          效果:可以換行
          2.(IE瀏覽器)使用樣式table-layout:fixed與nowrap
          eg.


          <style>
          .tb {table-layout:fixed}
          </style>

          <table class="tb" width="80">
          <tr>
          <td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
          </td>
          </tr>
          </table>


          效果:可以換行
          3. (IE瀏覽器)在使用百分比固定td大小情況下使用樣式table-layout:fixed與nowrap


          <style>
          .tb{table-layout:fixed}
          </style>

          <table class="tb" width=80>
          <tr>
          <td width=25% nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
          </td>
          <td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
          </td>
          </tr>
          </table>


          效果:兩個td均正常換行
          3.(Firefox瀏覽器)在使用百分比固定td大小情況下使用樣式table-layout:fixed與nowrap,并且使用div
          eg.


          <style>
          .tb {table-layout:fixed}
          .td {overflow:hidden;}
          </style>

          <table class=tb width=80>
          <tr>
          <td width=25% class=td nowrap>
          <div>abcdefghigklmnopqrstuvwxyz 1234567890</div>
          </td>
          <td class=td nowrap>
          <div>abcdefghigklmnopqrstuvwxyz 1234567890</div>
          </td>
          </tr>
          </table>


          這里單元格寬度一定要用百分比定義
          效果:正常顯示,但不能換行(注:在FF下還沒有能使容器內容換行的好方法,只能用overflow將多出的內容隱藏,以免影響整體效果)

          轉自:http://www.myhacker.org/oicq/article.asp?id=248

          posted on 2006-07-13 16:39 謝瑋 閱讀(228) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          主站蜘蛛池模板: 仙桃市| 吴江市| 渭南市| 房山区| 福州市| 平和县| 银川市| 呼玛县| 昌吉市| 明水县| 阿瓦提县| 乌鲁木齐县| 石城县| 祁门县| 郓城县| 新昌县| 怀安县| 开远市| 宜宾市| 遂川县| 宽甸| 龙陵县| 东辽县| 靖边县| 抚州市| 武功县| 阿荣旗| 桂林市| 岳普湖县| 南川市| 和田县| 白山市| 阳春市| 沾益县| 桃园市| 昆明市| 浪卡子县| 柞水县| 邻水| 成都市| 临武县|