My goal is to conceal a footer beneath the main content that will only become visible when the main content is scrolled above the footer itself. However, I am encountering an issue where setting the footer's z-index to a negative value successfully hides the footer, but renders the links unclickable.
In an attempt to resolve this issue, I experimented with increasing the z-index of the main content while setting the footer's z-index to zero. This approach, however, resulted in the footer being displayed above the main content.
Below is a snippet of the code I have been working with:
#main {
z-index:4;
padding:0px 0px 450px;
border-bottom:1px solid red;
}
#mainBg {
background:red;
}
footer {
padding: 50px 0;
bottom:0;
position:fixed;
z-index:0;
width:100%;
}
<body>
<div id="main">
<div id="mainBg">Lorem ipsum dolor sit amet... (content truncated for brevity)</div>
</div>
<footer>footer footer
<br/>
... (footer content truncated for brevity) ... <a href="http://google.co.uk">Google link</a>
<br/>footer footer
<br/>
<br/>
...
To further demonstrate this issue, I have included links to JSFiddles showcasing both scenarios: