【问题标题】:May be an IE z-index bug?可能是 IE z-index 错误?
【发布时间】:2023-03-16 23:05:01
【问题描述】:

下面是我的代码。

在ie浏览器中打开页面,然后选择div中的文字,文字会以阴影四边形空白显示。如果删除一行 z-索引:0, 在 css 类 test1 中,ie 将正确执行。

在我的项目中,z-index 必须设置大于零,所以我无法删除该行。

我找到了一个解决方案,当pannel.z-index大于0时设置bg_img.filter = "",那么ie也可以正常工作。但不幸的是,bg_img.filter.alpha 也必须设置。

那我该怎么办?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script language="javascript" src="scripts/im_test.js"></script>
    <title>test</title>
    <style type="text/css">
      .test1 {
        position:absolute;
        background:#ffffff;
        left:20px;
        top:20px;
        border:1px solid;
        width:198px;
        height:500px;
        filter: progid:DXImageTransform.Microsoft.Shadow(color="#999999", Direction=135, Strength=5);
        z-index:0;
      }
    </style>
    <script>

    function init ()
    {
      var pannel = document.createElement ('div');
      var bg_img = document.createElement ('div');
      var head = document.createElement ('div');

      pannel.setAttribute('class', 'test1');
      pannel.setAttribute('className', 'test1');

      bg_img.style.cssText = "position:relative;left:0px;top:0px;"
      + "width:198px;"
      + "height:500px;"
      + "filter:alpha(opacity=100);";

      head.style.cssText = "position:absolute;"
      + "left:0px;"
      + "top:0px;"
      + "width:180px;"
      + "height:20px;";

      document.body.appendChild (pannel);
      pannel.appendChild(bg_img);
      pannel.appendChild(head);

      head.innerHTML = "<div>yusutechasdf</div><div>innerhtml</div>"
    }
    </script>
  </head>
  <body onload="init()">
  </body>
</html>

【问题讨论】:

    标签: css internet-explorer javascript


    【解决方案1】:

    IE 与 z-index: 0; 存在问题,尝试将其设置为 1 并相应地调整其他 z-index。

    【讨论】:

      猜你喜欢
      • 2012-09-09
      • 2011-01-27
      • 2011-08-14
      • 2012-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-14
      相关资源
      最近更新 更多