日期:2014-05-17  浏览次数:20680 次

怎么定义div中的文字自动换行,或者是控制文本的长度
如题,设置div属性width的值也没有用。


------解决方案--------------------
word-break:break-all;
dispaly: block;
------解决方案--------------------
IE 7 下测试正常!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<title> new document </title>
<meta name= "generator " content= "editplus " />
<meta name= "author " content= " " />
<meta name= "keywords " content= " " />
<meta name= "description " content= " " />
<style type= "text/css ">
.wordWrapDiv
{
border: 1px solid red;
background-color: #ffff00;
width: 200px;
height: 100px;
word-break: break-all;
}
</style>
</head>

<body>
<div id= "divDisplay " class= "wordWrapDiv "> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊 </div>
</body>
</html>