简体   繁体   中英

Make click go through an element to one behind it

I have a div that spans my entire page with some buttons. The div however, is transparent. I have placed a video behind the div, that I would like to be able to start and stop. Of course, only when I press somewhere that isn't a button. But currently, the div is consuming the click. I would like the click to propagate to the element behind it. However, I would still like it to block swipes.

CSS

.root {
    display: grid;
    grid-template-columns: 0.7fr 1fr 0.7fr;
    grid-template-rows: 1fr;
    gap: 0px 0px;
    grid-template-areas: "left center right";
    height: 100vh;
    width: 100vw;
    position: absolute;
}

HTML

<div
   className="root"
   style={{
      display: "grid"
      width: `calc(100% - ${arg1? arg3: 0}px)`,
      height: `calc(100% - ${arg2 ? arg4: 0}px)`,
      backgroundColor: "#ffffff00",
   }}
   onClick={(ev) => {
      console.log("cl");
   }}
>

You need the pointer-events: none; css property.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM