Click through div to underlying elements

后端 未结 16 2065
逝去的感伤
逝去的感伤 2020-11-21 06:19

I have a div that has background:transparent, along with border. Underneath this div, I have more elements.

Curre

16条回答
  •  礼貌的吻别
    2020-11-21 06:47

    Yes, you CAN force overlapping layers to pass through (ignore) click events.
    PLUS you CAN have specific children excluded from this behavior...

    You can do this, using pointer-events

    pointer-events influences the reaction to click-, tap-, scroll- und hover events.


    In a layer that should ignore / pass-through mentioned events you set

    pointer-events: none; 
    

    Children of that unresponsive layer that need to react mouse / tap events again need:

    pointer-events: auto; 
    

    That second part is very helpful if you work with multiple overlapping div layers (probably some parents being transparent), where you need to be able to click on child elements and only that child elements.

    Example usage:

        
        
        
    

提交回复
热议问题