I recently added a scroll-to-top arrow using Jquery, and it's functioning flawlessly. However, I encountered an issue when I set body and html to a height of 100%, as it mysteriously disappears.
View this fiddle for reference
The HTML structure is as follows:
<body>
<main id="top">
........
main content here
....
</main>
<!-- Scroll to top arrow -->
<a href="#top" class="goto-top">Top</a>
</body>
CSS Styling
body, html {
overflow-x: hidden;
height: 100%; /* This line causing the issue */
}
main {
height:100%;
position: relative;
overflow-y: auto;
}
.goto-top {
display: inline-block;
height: 40px;
width: 40px;
bottom: 20px;
right: 20px;
position: fixed;
border-radius:50%;
overflow: hidden;
white-space: nowrap;
opacity:0;
z-index:999;
background:#CCCCCC;
visibility: hidden;
color:#111111;
}
Removing the 100% height from html and body resolves the issue. But I want to maintain them at 100%. Any suggestions on how to adjust the CSS for .goto-top, html, and body?
Note: The requirement is to keep body and html heights at 100%, not min-height.