zoukankan
html css js c++ java
CSS网页制作时实现自动换行的小技巧
大家都知道连续的英文或数字能是容器被撑大,不能根据容器的大小自动换行,下面是 CSS如何将他们换行的方法!
对于div
1.(IE浏览器)white-space:normal; word-break:break-all;这里前者是遵循标准。
#wrap{white-space:normal; 200px; }
或者
#wrap{word-break:break-all;200px;}
<
div
id
="wrap"
>
ddd1111111111111111111111111111111111
</
div
>
效果:可以实现换行
2.(Firefox浏览器)white-space:normal; word-break:break-all;overflow:hidden;同样的FF下也没有很好的实现方法,只能隐藏或者加滚动条,当然不加滚动条效果更好!
#wrap{white-space:normal; 200px; overflow:auto;}
或者
#wrap{word-break:break-all;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将多出的内容隐藏,以免影响整体效果)
青苹果Web应用商店
https://webapp.taobao.com/
PHP/ASP.NET/ASP/UCHOME/DISCUZ! X系列网站开发,详细需求联系
QQ:8511978
查看全文
相关阅读:
python开发_html_html处理
python开发_logging_日志处理
IIS 7 应用程序池自动回收关闭的解决方案
C#流水号生成汇总(四)
通过内存盘提高MSMQ的消息吞吐能力
c#分页工具类,完美实现List分页
IIS 未能从程序集“System.ServiceModel, Version=3.0.0.0, Culture=neutral,
win7电脑遇到端口被占用的情况该如何查看并将其关闭
如何创建内存盘
IP地址便捷修改器 V3.5 绿色版
原文地址:https://www.cnblogs.com/Dicky/p/401549.html
最新文章
python center, ljust, rjust
celery 实例进阶
python get方法
python操作redis
nginx 414 Request-URI Too Large
python enumerate
python中if __name__ == '__main__'
python 在不同层级目录import 模块的方法
求最大公约数之辗转相除法是什么鬼?
linux rwxrwxrwt文件夹属性
热门文章
linux查看文件夹大小
Linux 中如何卸载已安装的软件
Linux查看系统信息的一些命令及查看已安装软件包的命令
linux清空文件等有用的指令
存储基本概念
makefile
python开发_函数的参数传递
python开发_++i,i += 1的区分
python开发_json_一种轻量级的数据交换格式
python开发_platform_获取操作系统详细信息工具
Copyright © 2011-2022 走看看