当我将鼠标移到li元素上时,li元素的长内容应该换行。以下代码适用于除Internet Explorer 5之外的所有浏览器。您能帮我修复ie5吗?
<style type="text/css">
#breakText{
border: 1px solid #000;
width: 200px;
padding: 0px !important;
}
#breakText li{
margin: 0px !important;
padding: 8px;
margin: 48px auto 0;
white-space: nowrap;
overflow: hidden;
<!-- text-overflow: ellipsis; -->
display: block;
}
#breakText li:hover{
white-space: normal;
background-color: yellow;
}
</style>
&#13;
<html>
<head>
<script type="text/javascript" >
</script>
</head>
<body>
<ul id="breakText">
<li>This li contains a very long word: thisisaveryveryveryveryveryverylongword. The long word will break and wrap to the next line. </li>
<li> thisisaveryveryveryveryveryverylongword. The long word will break and wrap to the next line.</li>
</ul>
</body>
</html>
&#13;
答案 0 :(得分:1)
IE 5在锚标记“a”以外的元素上没有伪悬停。
只有具有href属性时才选择“a”标记。因此,您可能希望尝试检测悬停的更简单的情况。我们现在不再改变文本包装,而是使用文本颜色:
<style>
li:hover{color:red;} /* won't work */
a:hover{color:red;} /* this works */
</style>
<li>this won't change</li>
<a href=# onclick="return false;">this will change on hover</a>