javascript - IE6 : width or height set to 0px does not work when content inside

标签 javascript css

如果我想设置widthdiv包含一些文本,我想设置 width其中div0在 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/

相关文章:

jquery - 在 jQuery 的 CSS() 方法中设置 if 语句时遇到困难

css - Chrome 更改背景图片位置

javascript - redux如何管理store中的大数据?

javascript - 具有不同响应的 Web 服务。响应对象未定义

javascript - 尝试使用 chrome.downloads(由于某种原因未定义)

javascript - 追加到尚未插入文档的新节点

javascript - Window Object.print() 在 Chrome 中卡住

javascript - html5如何制作随机背景色

jquery - 背景图像未在 chrome 中呈现

html - 为什么父 div 不会和它的 child 一起成长