歲月如哥
          人生非夢
          posts - 50,comments - 144,trackbacks - 0

          自動換行的實現方法

          [ 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

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


          網站導航:
           
          主站蜘蛛池模板: 金门县| 新巴尔虎左旗| 昌黎县| 金溪县| 九台市| 宜宾市| 启东市| 昭苏县| 临清市| 忻城县| 蓬安县| 淳化县| 永善县| 祁连县| 贵南县| 中卫市| 盐津县| 庆云县| 将乐县| 乌海市| 视频| 黔西县| 新津县| 宝兴县| 黎川县| 石河子市| 南木林县| 鄱阳县| 革吉县| 诸城市| 威宁| 新兴县| 鲜城| 昌邑市| 册亨县| 河曲县| 云霄县| 确山县| 九寨沟县| 泸西县| 禄劝|