主页  范文大全   设计学院   SEO研究   免费资源   网赚大全  QQ资源区    电影下载  在线电影   短信&笑话   校内网   理财知识   站长Blog   访客留言   顶级QQ百科

         声明:本站所有资料素材均是由站长精心整理搜集的,属于原创。我们同意您的转载和复制,但是在转载复制时请保留文字出处。本站资料全部免费使用,无需注册,力求打造华北最强最大的免费资源网站。

大家都知道连续的英文或数字能是容器被撑大,不能根据容器的大小自动换行下面是 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 >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 >ddd1111111111111111111111111111111111111111</div>

效果:容器正常内容隐藏

对于table

1. (IE浏览器)使用样式table-layout:fixed;

<style>
.tb{table-layout:fixed}
</style>

<table width="80">
<tr>
<td>abcdefghigklmnopqrstuvwxyz 1234567890
</td>
</tr>
</table>

效果:可以换行

2.(IE浏览器)使用样式table-layout:fixed与nowrap

<style>
.tb {table-layout:fixed}
</style>

<table width="80">
<tr>
<td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
</td>
</tr>
</table>

效果:可以换行

3. (IE浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap

<style>
.tb{table-layout:fixed}
</style>

<table width=80>
<tr>
<td width=25% nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
</td>
<td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
</td>
</tr>
</table>

效果:两个td均正常换行

4.(Firefox浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div

<style>
.tb {table-layout:fixed}
.td {overflow:hidden;}
</style>

<table width=80>
<tr>
<td width=25% nowrap>
<div>abcdefghigklmnopqrstuvwxyz 1234567890</div>
</td>
<td nowrap>
<div>abcdefghigklmnopqrstuvwxyz 1234567890</div>
</td>
</tr>
</table>

这里单元格宽度一定要用百分比定义

效果:正常显示,但不能换行(注:在FF下还没有能使容器内容换行的好方法只能用overflow将多出内容隐藏以免影响整体效果)

教程录入:xxYsh.com    责任编辑:admin 
发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口

推荐链接