关于word-break,word-wrap换行
目前项目中有一些流程日志需要动态显示到页面上,实现方法是ajax动态获取附加到<span></span>标签上,然后设置word-break:break-all样式使其自动换行,word-break允许词间换行,针对长字符串,当超出外层div时换行,但是在chrome下显示正常,在IE8下就不起作用了,应用网上说的word-wrap:break-word;overflow:hidden,还是不行,解决方法是把span标签换成p标签,这里p是块级元素,那么直接在span上加display:block也是可以的;
这里网上查资料比较了word-break和word-wrap的区别,
word-wrap是控制换行的。
使用break-word时,是将强制换行。中文没有任何问题,英文语句也没问题。但是对于长串的英文,就不起作用。特别是一行中最后一个单词如果太长,它即使超过了div的宽度,也不会换行的。
word-break是控制是否断词的。
normal是默认情况,英文单词不被拆开。
break-all,是断开单词。在单词到边界时,下个字母自动到下一行。主要解决了长串英文的问题。
keep-all,是指Chinese, Japanese, and Korean不断词。即只用此时,不用word-wrap,中文就不会换行了。(英文语句正常。)
ie下:
使用word-wrap:break-word;所有的都正常。
ff下:
如这2个都不用的话,中文不会出任何问题。英文语句也不会出问题。但是,长串英文会出问题。
为了解决长串英文,一般用word-wrap:break-word;word-break:break-all;。但是,此方式会导致,普通的英文语句中的单词会被断开(ie下也是)。
目前主要的问题存在于 长串英文 和 英文单词被断开。其实长串英文就是一个比较长的单词而已。
即英文单词应不应该被断开那?那问题很明显了,显然不应该被断开了。
对于长串英文,就是恶意的东西,自然不用去管了。但是,也要想些办法,不让它把容器撑大。
用:overflow:auto; ie下,长串会自动折行。ff下,长串会被遮盖。
最好的方式是word-wrap:break-word;overflow:hidden;
而不是word-wrap:break-word;word-break:break-all;。
word-wrap:break-word;overflow:auto;在ie下没有任何问题。在ff下,长串会被遮住部分内容。
这里又延伸到文字间距的两个属性
letter-spacing定义了字与字之间的距离.
word-spacing是控制字与字之间空格的宽度.
关于word-break,word-wrap换行的更多相关文章
- 17. Word Break && Word Break II
Word Break Given a string s and a dictionary of words dict, determine if s can be segmented into a s ...
- LeetCode之“动态规划”:Word Break && Word Break II
1. Word Break 题目链接 题目要求: Given a string s and a dictionary of words dict, determine if s can be seg ...
- LeetCode ||& Word Break && Word Break II(转)——动态规划
一. Given a string s and a dictionary of words dict, determine if s can be segmented into a space-sep ...
- leetcode@ [139/140] Word Break & Word Break II
https://leetcode.com/problems/word-break/ Given a string s and a dictionary of words dict, determine ...
- word break和word wrap
默认情况下,如果同一行中某个单词太长了,它就会被默认移动到下一行去: word break(normal | break-all | keep-all):表示断词的方式 word wrap(norma ...
- [LeetCode] Word Break II 拆分词句之二
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each ...
- 【leetcode】Word Break II
Word Break II Given a string s and a dictionary of words dict, add spaces in s to construct a senten ...
- LeetCode:Word Break II(DP)
题目地址:请戳我 这一题在leetcode前面一道题word break 的基础上用数组保存前驱路径,然后在前驱路径上用DFS可以构造所有解.但是要注意的是动态规划中要去掉前一道题的一些约束条件(具体 ...
- LeetCode Word Break II
原题链接在这里:https://leetcode.com/problems/word-break-ii/ 题目: Given a string s and a dictionary of words ...
- 【LeetCode OJ】Word Break II
Problem link: http://oj.leetcode.com/problems/word-break-ii/ This problem is some extension of the w ...
随机推荐
- 【转】Android:Animation的简单学习--不错
原文网址:http://blog.csdn.net/huangbiao86/article/details/6683665 Animation动画效果.提供了一系列的动画效果,可以应用大多数 的控件. ...
- C# 防止同一个账号多次登录(cache方法)
c#中防止同一账号重复登录的方法有不少,比如用数据库来记录用户登录情况.用Application来保存用户登录信息.用Cache来保存信息等. 本文为大家介绍如何利用缓存Cache方便地实现此功能. ...
- ASP.NET(C#) GridView (编辑、删除、更新、取消)
转自:http://my.oschina.net/dldlhrmc/blog/93458 前台代码 view source print? 01 <%@ Page Language=" ...
- HDU-2562 奇偶位互换
http://acm.hdu.edu.cn/showproblem.php?pid=2562 奇偶位互换 Time Limit: 3000/1000 MS (Java/Others) Memor ...
- python 默认的系统编码 sys.setdefaultencoding
python2.x的编码问题有时让人很头疼,一会ascii,一会unicode. 在脚本里多见这样的操作: import sys reload(sys) sys.setdefaultencoding( ...
- 《应用Yii1.1和PHP5进行敏捷Web开发》学习笔记(转)
学习地址为: http://www.yiibook.com/book/agile_web_application_development_with_yii1.1_and_php5 1.建立应用程序 ...
- Command-line interface
A command-line interface (CLI), also known as command-line user interface, console user interface, a ...
- .jar是什么文件?(转载)
JAR(Java ARchive,Java 归档)是一种与平台无关的文件格式,可将多个文件合成一个文件.用户可将多个 Java applet 及其所需组件(.class 文件.图像和声音)绑定到 JA ...
- Flex开发小结(1)如何使用AdvancedDataGrid
1.AdvancedDataGrid扩展了普通DataGrid的功能,AdvancedDataGrid控件提供了另外一些特性,并在数据显示.数据聚合和数据格式化方面有着强大的控制力. 这里我主要说一下 ...
- 谷歌google搜索打不开、谷歌gmail邮箱及相关服务无法登录的解决的方法
歌打不开 google打不开,与中国大陆封杀有关,可是主要是由于近期googleserver在全球范围内又一次进行了布局调整. 解决的方法是仅仅要改动用户本地计算机hosts文件就能够了. 一.Win ...