IE错误:绝对定位的元素具有不透明的背景颜色 [英] IE bug: absolutely-positioned element with a non-transparent background colour

查看:86
本文介绍了IE错误:绝对定位的元素具有不透明的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绝对定位的DIV,我需要捕获onclick事件。事实证明,在IE7中,DIV似乎没有足迹的东西,如点击甚至光标。例如:

I have an absolutely-positioned DIV that I need to trap onclick events for. It turns out that, in IE7, the DIV seems to have no 'footprint' for things like clicking and even cursor. For example:

div {
      width: 200px; height: 200px;
      position: absolute;
      border: 10px solid black;
      cursor: pointer;
}

在IE7中,DIV没有footprint到onclick(),并且其游标不会更改为指针。奇怪的是,它处理它的边界上的那些 - 因此在这个例子中的大边框。设置背景颜色:

In IE7, that DIV has no 'footprint': it doesn't react to onclick(), and its cursor doesn't change to the pointer. Curiously, it DOES handle both those over its border - hence the large border in this example. Setting a background-color:

div { background-color: #fff; }

可解决问题。但是,在这种情况下,这是不可能的 - 我需要DIV有一个透明的背景。

fixes the problem. But, in this case, that's not possible - I need the DIV to have a transparent background.

我在过去遇到这个bug,但我不能

I've come across this bug in the past, but I cannot for the life of me remember the IE hack to fix it.

推荐答案

尝试使用透明的背景图片。

Try using a transparent background image.

我建议使用2x2或更大的 .gif 这是所有的透明像素。将其设置为在 x y 上重复,并且IE不应该有点击问题。

I would suggest using a 2x2 or bigger .gif that is all transparent pixels. Set it to repeat on x and y and IE shouldn't have an issue with the clicks.

background: transparent url(path/to/spacer.gif) repeat left top;
/* Not all of that is necessary, but I have a tendency to define it anyway. */

这篇关于IE错误:绝对定位的元素具有不透明的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆