Situation:
Consider the following scenario with a simplified HTML example:
- position the footer behind the content and make it stick to the bottom
- when reaching the end of the page, the footer should slide up from behind the content
I achieved this layout successfully. However, when I set both the overflow-x
properties of the html
and body
elements to hidden
, the links in the footer become unclickable.
Update on the situation:
I am aware that adjusting the z-index values for #content
to 2 and for footer
to 1 can make the links clickable. Nevertheless, this solution conflicts with a multizoom.js feature in another section of the webpage, which I want to avoid.
Question:
What is the relationship between setting the overflow-x
property for both the html
and body
elements and the functionality of the footer links? Why is it necessary for both elements to have this property set? (If one of them excludes overflow-x
, the links work as expected)
Currently, I don't face any issues by not defining overflow-x
in my current project as it was an outdated styling attempt that has already been removed. However, I'm curious about the peculiar behavior observed earlier.
Example:
/* The following CSS prevents the footer links
* from being clickable */
html, body {
overflow-x: hidden;
}
/* Supporting styles to position the footer behind content
* and make it sticky at the bottom */
#content {
background: lightgrey; /* opaque bg color */
border-bottom: 1px solid black; /* border for content ending */
height: 1500px; /* arbitrary height for scrolling trigger */
margin-bottom: 120px; /* margin to reveal footer after scrolling */
}
footer {
background: grey; /* distinguish footer visually */
padding: 50px; line-height: 20px; text-align: center; /* footer design */
z-index: -1; position: fixed; /* place footer behind content while sticking to bottom */
bottom: 0; width: 100%; /* full-width positioning */
}
body {
margin: 0; /* use whole panel area */
}
<html>
<body>
<div id="content">
Scroll down to reach the end of the page.
</div>
<footer>
<a href="#">Footer link here (currently unclickable)</a>
</footer>
</body>
</html>