Jump to content
Search Community

SmoothScroll + Sticky Nav issue

Adesh test
Moderator Tag

Recommended Posts

Hi,

 

The reason you're seeing this behaviour is because once you add a transform to an element, anything with position: fixed won't work as expected:

https://stackoverflow.com/a/15256339/2456879

 

The solution is to move the <nav> element outside the transformed wrapper:

<div class="main">
  <nav>Header</nav>
  <div class="page--wrapper">
    <section style="background-color: red">Section1</section>
    <section style="background-color: yellow">Section2</section>
    <section style="background-color: blue">Section3</section>
    <section style="background-color: green">Section4</section>
  </div>
</div>
nav {
  background-color: black;
  height: 50px;
  text-align: center;
  color: #fff;
  font-size: 20px;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}
section {
  height: 100vh;
  font-size: 100px;
  color: #fff;
  text-align: center;
}

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...