歲月如哥
          人生非夢
          posts - 50,comments - 144,trackbacks - 0
          <2008年4月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          常用鏈接

          留言簿(11)

          隨筆分類(45)

          相冊

          收藏夾(21)

          friends

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          自動換行的實現方法

          [ 2006-02-24 22:42:39 pm | 作者: Bijia ]
          字體大小: | |
          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將多出的內容隱藏,以免影響整體效果)
          posted on 2008-04-17 10:28 歲月如歌 閱讀(308) 評論(0)  編輯  收藏 所屬分類: css

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


          網站導航:
           
          主站蜘蛛池模板: 巴林右旗| 千阳县| 永修县| 夏河县| 屏边| 习水县| 电白县| 宝兴县| 修武县| 华池县| 大埔县| 万州区| 交口县| 万盛区| 阿图什市| 肥乡县| 吉林市| 鞍山市| 利辛县| 海丰县| 淳安县| 新民市| 玛曲县| 鹿邑县| 喀喇沁旗| 博乐市| 胶南市| 明溪县| 三明市| 阿瓦提县| 龙海市| 宜兴市| 延安市| 宝山区| 丽江市| 海原县| 蒙城县| 资兴市| 营山县| 白朗县| 宽甸|