click link below a higher z-index div [duplicate]

2019-01-11 09:56发布

问题:

Possible Duplicate:
Passing mouse clicks through an overlaying element <div>

Is it possible to click the link below the red square without javascript? The red div doesn't need to be clickable.

http://jsfiddle.net/efortis/LNwHV/

#bottom{
 width: 100px;
 height: 100px;
 background-color: orange;
}

#top{
  width: 50px;
  height: 50px;
  position: absolute;
  left:0;
  top:0;
  background-color: rgba(255,0,0,.5);
 }

回答1:

The CSS method to do this is pointer-events: none

See: http://jsfiddle.net/LNwHV/1/

Browser support: http://caniuse.com/pointer-events (works everywhere except IE10 and older)

To support old versions of IE, you'll have to use JavaScript as a fallback.