How can I disable clicks but still allow scrolling in an iframe?

前端 未结 1 958
执笔经年
执笔经年 2021-02-13 05:26

I have an iframe showing on my page in a panel of a fixed height but the page rendered in the iframe is much larger. I don\'t want the user to be able to click on anything in th

1条回答
  •  你的背包
    2021-02-13 05:47

    If you don't want the contents of the iframe to be interactable by the user, you can disable pointer-events on it. But as you want it to be scrollable, just put a full sized iframe in a smaller div with overflow: scroll.

    div {
      width: 50vw;
      height: 50vh;
      overflow: scroll;
    }
    
    iframe {
      width: 100vw;
      height: 100vh;
      pointer-events: none;
    }

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