I'm hitting a problem with a p5js integration in a webpage. I'm trying to get two paragraph elements, positioned before and after an iframe, to overlap that iframe, whilst still allowing the iframe to be clickable, and still allowing the links in the paragraph elements to be clickable. I've fiddled around and read a lot about how z-index works and about pointer-events but I couldn't find a solution in these. Here is the minimal reproducible example :
The example works as intended with the bottom text, but the top text is being overlapped wrong.
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.js"></script>
<!DOCTYPE html>
<html>
<head>
<style>
#roll {
width: 500px;
margin-right: auto;
margin-left: auto;
}
p {
position: relative;
font-size: 1.5em;
}
.codepoem {
width: 500px;
height: 200px;
}
.codepoem iframe {
position: relative;
width: calc(500px + 20vw);
margin-left: -10vw; /* center horizontal */
height: calc(200px + 40vh);
margin-top: -20vh;/* center vertical */
/*z-index:1;*/
}
</style>
</head>
<body>
<div id="roll">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vulputate et libero sit amet blandit. Integer mollis felis dui, vitae euismod nunc tincidunt sed. Aliquam eget libero sed ante interdum consectetur. Quisque a vulputate lorem. Morbi sit
amet
<a href="">scelerisque turpis.</a></p>
<div class="codepoem">
<iframe src="https://editor.p5js.org/itsKaspar/embed/wUWKbsui6"></iframe>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<a href="">scelerisque turpis.</a> Fusce vulputate et libero sit amet blandit. Integer mollis felis dui, vitae euismod nunc tincidunt sed. Aliquam eget libero sed ante interdum consectetur. Integer a placerat magna. </p>
</div>
</body>
</html>
note : I've purposefully created a container for the iframe to aid it in its underlapping behavior which direction could I go in from now ? is there a simple solution I am not seeing ? Thanks a lot