1Next >
99163 | 发表于:10-09-08 18:53 [添加收藏] 楼主 [回复] #Top# |
---|---|
人气:865
积分:1901
金币:6081
|
大家都知道连续的英文或数字能是容器被撑大,不能根据容器的大小自动换行,下面是 CSS如何将他们换行的方法!
对于div
1.(IE浏览器)white-space:normal; word-break:break-all;这里前者是遵循标准。
#wrap{white-space:normal; width:200px; } 或者 #wrap{word-break:break-all;width:200px;} <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; } <div id="wrap">ddd1111111111111111111111111111111111111111</div> 效果:容器正常,内容隐藏
对于table
1. (IE浏览器)使用样式table-layout:fixed;
<style> .tb{table-layout:fixed} </style> <table class="tbl" width="80"> <tr> <td>abcdefghigklmnopqrstuvwxyz 1234567890 </td> </tr> </table> 效果:可以换行
2.(IE浏览器)使用样式table-layout:fixed与nowrap
<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
<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将多出的内容隐藏,以免影响整体效果)
Ta最近还发表过
[其他]
请问还有多少老用户在
(18-02-24)
[模板]
这次真的搞不定,三级dropdown弹出菜单。
(18-02-10)
[使用]
修改碎片的文本框为编辑器 源文件下载 无错
(18-01-18)
[使用]
如何尽快解决购物车white.gif图标问题
(17-12-10)
[使用]
还有人在用KINGCMS PHP吗 感觉好淡了。。
(17-10-15)
随机阅读
[使用]
如何实现网页中的文字或字母替换?
(14-06-27)
[建议]
PHP企业版的sprite图改进建议
(13-05-14)
[分享]
如何做好SEO中的链接策略
(13-05-02)
[分享]
利用QQ群营销推广的技巧分享
(12-02-15)
[使用]
请手工删除_cache/portal目录
(11-01-03)
|
jiaoda015 | 发表于:11-04-28 17:24 沙发 [回复] #Top# |
---|---|
人气:15
积分:1
金币:640
|
学习了
|
lifetraveler | 发表于:11-06-05 01:34 板凳 [回复] #Top# |
---|---|
人气:5
积分:229
金币:415
|
学习了
|
1Next >