1Next >
99163 | 发表于:10-09-08 18:53 [添加收藏] 楼主 [回复] #Top# |
---|---|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
大家都知道连续的英文或数字能是容器被撑大,不能根据容器的大小自动换行,下面是 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)
随机阅读
[建议]
建议大C公布K9发布时间,支持的进来顶贴
(12-08-02)
[疑问]
kingcms 企业版(php) nginx下出错
(12-06-14)
[其他]
KC很猛啊,PR6
(11-08-23)
[其他]
母亲节在即看几大门户的战术
(11-05-10)
[错误]
KingCMS企业版(PHP) 6.0.970(Sp1)留言反馈bug
(11-04-15)
|
jiaoda015 | 发表于:11-04-28 17:24 沙发 [回复] #Top# |
---|---|
![]() ![]() ![]() ![]() |
学习了
|
lifetraveler | 发表于:11-06-05 01:34 板凳 [回复] #Top# |
---|---|
![]() ![]() ![]() |
学习了
|
1Next >