I have a webpage where the bottom part is occupied by an iframe that I made transparent to view the overlapped elements.
Although the transparency is working well, the overlapped links are not clickable unless I switch pointer-events to none in the iFrame (which obviously solves the problem by another). I tried making a div into the iFrame, covering the "menuless" part, with pointer-events set to all but it doesn't seem to work. I also have to keep in mind the chat component is sticky.
This question is old, but for anyone who stumbles across it...
iFrames
represent another entire DOM wrapped in the parent DOM. Things like CSS pointer-events
don't typically work on iFrames or function the same way across browsers.
You can try to impact all content INSIDE the iframe using iframe > * {pointer-events: none;}
but if the iframe content crosses domains, it likely won't work.
pointer-events: all;
is intended to work with SVGs only not other DOM elements.
The proper solution for the OP is to either scale the iFrame to only the size of the content OR don't use an iFrame at all.
Other options to embed content:
HTML <embed>
- Docs
HTML <object>
- Docs
Web Components HTML Imports - Recently deprecated but there's a polyfill
None of these are great solutions but depending on the problem they may work.
Finally, you can use a Javascript call to fill the content of an element with external content. This is essentially what "Single Page" Apps built using React/Angular/Vue are doing behind the scenes. Note: If you go this route be sure to pay attention to CORS headers
if the content is coming from a different domain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With