web前端|html教程
div+CSS里长英文字母如何自动换行?
web前端-html教程
自动换行问题,正常字符的换行是比较合理的,而连续的数字和英文字符常常将容器撑大,挺让人头疼,下面介绍的是CSS如何实现换行的方法
黑洞效果源码,怎么利用vscode打包,ubuntu进程总数,tomcat 301重定,sqlite多列、唯一约束,B站数据爬虫与可视化报告,新浪php招聘,常州seo推广价格优惠,算命网站程序,dede模板网lzw
最佳CSS定义换行代码
asp源码 官方下载,ubuntu下载的慢,爬虫拨号代理ip,php each(),seo 检测链接lzw
.wrap { table-layout:fixed; word-break: break-all; overflow:hidden; }
这里 overflow:hidden;或者 auto; 对于div,p等块级元素
正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义的宽度之后自动换行
html
付费视频源码,vscode cmd调试,ubuntu解包安卓固件,java模仿tomcat,vc怎么连接sqlite,javascript轮播图插件下载,网站前端js框架,爬虫生存环境,php 替换内容,seo运营是什么,手机微信网站源码,网页嵌套音乐播放器,软件下载类模板,dedecms高级搜索页面,论文设备材料管理系统,JYmusic音乐程序 v1.03lzw
正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义
css
#wrap{white-space:normal; width:200px; }
1.(IE浏览器)连续的英文字符和阿拉伯数字,使用word-wrap : break-word ;或者word-break:break-all;实现强制断行
#wrap{word-break:break-all; width:200px;}
或者
#wrap{word-wrap:break-word; width:200px;}
abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111
效果:可以实现换行
2.(Firefox浏览器)连续的英文字符和阿拉伯数字的断行,Firefox的所有版本的没有解决这个问题,我们只有让超出边界的字符隐藏或者,给容器添加滚动条
#wrap{word-break:break-all; width:200px; overflow:auto;}
abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111
效果:容器正常,内容隐藏
对于table
1. (IE浏览器)使用 table-layout:fixed;强制table的宽度,多余内容隐藏
效果:隐藏多余内容
2.(IE浏览器)使用 table-layout:fixed;强制table的宽度,内层td,th采用word-break : break-all;或者word-wrap : break-word ;换行
效果:可以换行
3. (IE浏览器)在td,th中嵌套div,p等采用上面提到的div,p的换行方法
4.(Firefox浏览器)使用 table-layout:fixed;强制table的宽度,内层td,th采用word-break : break-all;或者word-wrap : break-word ;换行,使用overflow:hidden;隐藏超出内容,这里overflow:auto;无法起作用
效果:隐藏多于内容
5.(Firefox浏览器) 在td,th中嵌套div,p等采用上面提到的对付Firefox的方法
运行代码框
最后,这种现象出现的几率很小,但是不能排除网友的恶搞。
下面是提到的例子的效果
div All white-space:normal;
Wordwrap still occurs in a td element that has its WIDTH attribute set to a value smaller than the unwrapped content of the cell, even if the noWrap property is set to true. Therefore, the WIDTH attribute takes precedence over the noWrap property in this scenario
IE \ word-wrap : break-word ;
abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111
IE \ word-break:break-all;
abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111
Firefox/ word-break:break-all; overflow:auto;
abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111
table table-layout:fixed;
table-layout:fixed; word-break : break-all; word-wrap : break-word ;
FF \ table-layout:fixed; overflow:hidden;
如果觉得《div+CSS里长英文字母如何自动换行?【HTML】》对你有帮助,请点赞、收藏,并留下你的观点哦!