大家都知道連續的英文或數字能是容器被撐大,不能根據容器的大小自動(dòng)換行,下面是 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下也沒(méi)有很好的實(shí)現方法,只能隱藏或者加滾動(dòng)條,當然不加滾動(dòng)條效果更好!
#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瀏覽器)使用樣式;
eg.
<style>.tb{}</style><table class="tbl" width="80"><tr><td>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>2.(IE瀏覽器)使用樣式與nowrap
eg.
<style>.tb {}</style><table class="tb" width="80"><tr><td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>3. (IE瀏覽器)在使用百分比固定td大小情況下使用樣式與nowrap
<style>.tb{}</style><table class="tb" width=80><tr><td width=25% nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td><td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>3.(Firefox瀏覽器)在使用百分比固定td大小情況下使用樣式與nowrap,并且使用div
eg.
<style>.tb {}.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下還沒(méi)有能使容器內容換行的好方法,只能用overflow將多出的內容隱藏,以免影響整體效果)
聯(lián)系客服