Hi there Webflowers!
I have an idea for a semi-fixed navbar effect, but I have no idea how to create it in webflow.
I’ve made a sketch, so you can see what is it all about:
Orange rectangle is your browser window. The blue section is a classic hero section with some hero heading in it. When you start scrolling, hero section have to shrink somehow to form a fixed menu on the top.
First of all, how do i get all the content after the hero section not to show above the fixed menu when scrolled, if the menu has a top margin of let’s say 100px?
Would appreciate any ideas on such tricky matter!
Well, I might misslead you a bit, but i didn’t really knew how to name this effect. If the blue hero section had only blue bg, I guess I could just make the navbar fixed, filled with the same color, but I need it to have a gradient bg with some non-repeatable pattern. In addition it should shrink to a certain height, and stay this way. On top of that, all the hero section content should disappear before leaving the section (suppose this can be done with some interactions?).
Sorry again for confusing title! How would you name this effect?
Ok, it sounds like some complex interaction. Maybe you could create such structure, as an example, and share the read-only link here. Then we could try to play around with that for getting the effect that you need.
Basically, once you scroll down a bit, have js add a class (.flexy-header) to a hero section wrapper. You can then style the newly classed .hero.flexy-header and its children. It can adjust smoothly if you add some CSS transition properties.
Change 100 to another number. 100 represents how many pixels down from the top the animation begins.
<script>
// When the window loads, note the scroll position
// and add and remove classes accordingly
$(window).scroll(function() {
if ($(this).scrollTop() > 100) {
$('.hero').addClass("flexy-header");
} else {
$('.hero').removeClass("flexy-header");
};
});
</script>
Sorry, I couldn’t figure this out with just webflow interactions.