css text 自动换行的实现方法 Internet Explorer,Firefox,Opera,Safar
2010-11-18 20:22
441 查看
代码 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3
4 <head>
5 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
6 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7 <title>css自动换行的实现方法 Internet Explorer,Firefox,Opera,Safari</title>
8 <meta name="Author" content="涂聚文 Geovin Du" />
9 <meta name="Keywords" content= " css, Cascading, Style, Sheets " />
<meta name="Description" content="CSS -Cascading Style Sheets. " />
<link rel="shortcut icon" href="http://www.dupcit.com/favicon.ico" type="image/x-icon" />
<link rel="icon" href="http://www.dupcit.com/favicon.ico" type="image/ico" />
<script type="text/javascript">
//计算文本,参数为:显示文本长度,层ID
function toBreakWord(intLen, id){
var obj=document.getElementById(id);
var strContent=obj.innerHTML;
var strTemp="";
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+"<br>";
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+= strContent;
obj.innerHTML=strTemp;
}
</script>
<style type="text/css">
/**/
.intro{
position:absolute;
color:white;
background:#d29b5a;
font-size:14px;
width:120px;
line-height:20px;
height:119px;
padding:5px;
margin:8px 0px 0px 10px;
text-align:left;
word-break:break-all; /*IE 允许词内换行*/
word-wrap:break-word; /*IE 内容将在边界内换行*/
overflow:auto;
}
</style>
</head>
<body>
<div class="intro">人生是一种心境,生活是一种艺术,成功是一种心态,幸福是一种感觉,竞争是一种建构,情感是一种整合,学习是一种成长.--涂聚文</div>
<script type="javascript">toBreakWord(10, "intro");</script>
</body>
</html>
2 <html xmlns="http://www.w3.org/1999/xhtml">
3
4 <head>
5 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
6 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7 <title>css自动换行的实现方法 Internet Explorer,Firefox,Opera,Safari</title>
8 <meta name="Author" content="涂聚文 Geovin Du" />
9 <meta name="Keywords" content= " css, Cascading, Style, Sheets " />
<meta name="Description" content="CSS -Cascading Style Sheets. " />
<link rel="shortcut icon" href="http://www.dupcit.com/favicon.ico" type="image/x-icon" />
<link rel="icon" href="http://www.dupcit.com/favicon.ico" type="image/ico" />
<script type="text/javascript">
//计算文本,参数为:显示文本长度,层ID
function toBreakWord(intLen, id){
var obj=document.getElementById(id);
var strContent=obj.innerHTML;
var strTemp="";
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+"<br>";
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+= strContent;
obj.innerHTML=strTemp;
}
</script>
<style type="text/css">
/**/
.intro{
position:absolute;
color:white;
background:#d29b5a;
font-size:14px;
width:120px;
line-height:20px;
height:119px;
padding:5px;
margin:8px 0px 0px 10px;
text-align:left;
word-break:break-all; /*IE 允许词内换行*/
word-wrap:break-word; /*IE 内容将在边界内换行*/
overflow:auto;
}
</style>
</head>
<body>
<div class="intro">人生是一种心境,生活是一种艺术,成功是一种心态,幸福是一种感觉,竞争是一种建构,情感是一种整合,学习是一种成长.--涂聚文</div>
<script type="javascript">toBreakWord(10, "intro");</script>
</body>
</html>
相关文章推荐
- firefox css自动换行的实现方法
- firefox css自动换行的实现方法
- CSS实现文字自动换行(兼容Firefox)
- Eclipse 格式化代码时不换行与自动换行的实现方法
- ProcessDialogKey 方法实现回车自动换行
- 在区域内绘制宽字符串多行自动换行的c语言实现方法
- IE, FireFox, Opera 浏览器支持CSS实现Alpha半透明的方法
- 绘制在某个矩形区域内字符串自动多行换行的一个方法(c)语言实现
- 禁止浏览器后退的一种实现方法,在IE, Firefox, Safari, Chrom 和 Opera上测试通过
- IE, FireFox, Opera 浏览器支持CSS实现Alpha半透明的方法
- IE, FireFox, Opera 浏览器支持CSS实现Alpha半透明的方法
- 自动换行问题,而连续的数字和英文字符常常将容器撑大,下面介绍的是CSS如何实现换行的方法
- css控制文字自动换行的实现方法
- css 不换行 自动换行 强制换行的实现方法
- Eclipse 格式化代码时不换行与自动换行的实现方法
- firefox英文字符串不自动换行问题的解决方法
- css中实现字符超出宽度自动换行和英语字符不断行的解决方法
- CSS实现连续数字和英文的自动换行的方法
- Eclipse-格式化代码时不换行与自动换行的实现方法
- CSS让网页(Li)中的内容自动换行的实现方法