My issue revolves around 2 divs: one containing a link and the other a box-shaped container. The link is set with position:fixed;
causing it to fly over the container div. To resolve this, I attempted to assign a negative z-index value to the link, but unfortunately, the hover state ceased to function unless I scrolled an equivalent amount as the height of the container div – typically around 3 scrolls before the hover state reactivated.
HTML
<div id="div-1">
<div class="container"></div>
</div>
<!-- additional div elements -->
<div id="div-2">
<a href="#">This is a link</a>
</div>
CSS
#div-2 a{
width:13%;
height:auto;
padding:0.5em 2.3em;
display:block;
position:fixed;
font-weight:500;
font-size:1.09em;
text-align: center;
background-color: none;
text-decoration:none;
outline:none;
z-index:0;}
#div-1{
...CSS properties...
}
An important note: The container remains hidden via JQuery unless a specific button is clicked.
JQuery code...
After trying various approaches, such as adjusting the z-index values for both the container and link, the issue persists.
Update: I am considering changing the CSS property "z-index", specifically when the container button is toggled on.
Therefore, the link will feature z-index:-9;
only when the container is visible. When the container is toggled off, the z-index should either be removed or remain at default.
I'm struggling with implementing this concept using jQuery, and my current attempt still results in the z-index remaining active when the container is toggled off. How can I properly remove or reset the z-index value?
Any alternative solutions to this problem are welcomed.