I have images wrapped up in a number of parent divs to create an outlined box offset compared to the image itself. Each image is a link to a page. This is what it looks like:
<div id="boxes-wrapper">
<div class="cointainer" id="container1">
<div class="box-border">
<div class="image-wrapper">
<div class="image-size">
<a href="..\pages/centri.html"><img id="img1" src="..\photos/titlepage/batch35.jpg" alt="Centri Sociali di Milano"/>
<h5>Centri Sociali di Milano</h5></a>
</div>
</div>
</div>
</div><!--boxes wrapper-->
I have script that reduces opacity of images until one is hoevered. Hovered image gains opacity 1, others drop opacity more. On mouseleave, all images return to hard-coded opacity. This part works fine- as long as the images can be hovered!
The .image-size
div often covers up the images. It somehow gets a higher z-index because of the opacity change of its child. As a result, the hover event does not trigger for img
elements because they are stacked behind the .image-size
. Therefore, the links are unclickable unless you find the sliver of image that can be clicked.
Here is a link to a working CodePen. The script affects opacity and only works on the outer edges of some photos because of this z-index layering.
https://codepen.io/WallyNally/pen/PGYVgX
I just need the img
s to get the highest z-index so that they may be on top. That should fix everything. Unfortunately, setting their z-index does not change anything. All elements in the document have been positioned . I can change the z-index of their parents to -1, but then the grandparent takes priority. You can keep doing this until you reach body
. Once body
and html
have been set to -1, you are right back where you started.
Does anybody have a solution? I'm all stumped out on this one.