如果我想设置width
的 div
包含一些文本,我想设置 width
其中div
至 0
在 IE6 中(我没有在 IE7 中检查过)不起作用!!!
请检查以下 HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript"></script>
<style>
#box {
width: 0px;
background-color: blue;
}
</style>
</head>
<body>
<div id="box"><span>hello</span></div>
<script>
$("#box").width(0);
</script>
</body>
</html>
div
的宽度坚持 div
的最小内容宽度.
问候,
穆尼姆
最佳答案
如果需要内容被 chop ,使用overflow:hidden
。没有它,布局会将框的大小视为 0,但不适合的内容将延伸到其容器之外。
关于javascript - IE6 : width or height set to 0px does not work when content inside,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3795578/