Pass click events through a DOM layer

后端 未结 4 1954
轻奢々
轻奢々 2021-01-14 09:03

I have a div that is positioned to the bottom of the page and sits above everything on the page. I include a shadow to remove the harsh cutoff of the content below. However,

相关标签:
4条回答
  • 2021-01-14 09:15

    You should implement your own event chain.

    For example:

    $('.shadow').click(function() {
        $('.under-shadow').trigger('click');
    });
    

    Althought it would work, I wouldn't recommend the use of pointer-events:none; since it isn't well supported.

    0 讨论(0)
  • 2021-01-14 09:16

    Try setting the pointer-events to none; for the overlaying div. See this page for an example: http://css-tricks.com/almanac/properties/p/pointer-events/

    0 讨论(0)
  • 2021-01-14 09:22

    you can add

    pointer-events:none;
    

    to your .bottom-wrap class in your CSS

    http://jsfiddle.net/aY2Ld/1/

    EDIT : you'll also need to add pointer-events:fill; to the .bottom class

    Updated Fiddle: http://jsfiddle.net/aY2Ld/4/

    0 讨论(0)
  • 2021-01-14 09:24

    If browser support is not a probleme fore you, you can use the CSS properties pointer-events

    .bottom-wrap {
        pointer-events:none;
    }
    

    But to make the content inside active, you need to reset it like that :

    .bottom-wrap .bottom {
        pointer-events:auto;
    }
    

    Fiddle : http://jsfiddle.net/aY2Ld/5/

    0 讨论(0)
提交回复
热议问题