Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sticky menu on scroll

Featured Replies

Hi everyone,

 

Was wondering if anyone out in the big wide world could help me with a niggling problem.

 

Ok so I am designing a website for a client. I would like to create a sticky menu that appears only on scroll. This initially is fine as I can easily create a sticky menu that goes to a fixed position on scroll. What I want is something like this (see weblink here):

 

http://themes.muffingroup.com/be/pole/

 

You see how the menu disappears off the top of the page and then the sticky fixed menu appears after. How on earth did they create this?!

 

Here is the webpage I am currently working on:

 

http://thehmcom.qublu.com/test-page/

 

I am using WordPress with a Headway theme. I have effectively created two wrappers to act as each menu. The first wrapper (which is for the initial menu) contains the logo and navigation, is transparent and has been assigned the CSS class 'navhead'. The position has also been set to Absolute (so it overlaps the image behind/underneath).

 

The second wrapper (to be used as the sticky menu) has a white background and only the logo centred in it (just to see the difference). This has been assigned the CSS class 'stickytop'. This position has been set to Fixed, at Top 0px.

 

I have added the following script to my header:

 

<script>
$(function(){
$(window).scroll(function() {
if ($(this).scrollTop() >= -10) {
$('navhead').addClass('stickytop');
}
else {
$('navhead').removeClass('stickytop');
}
});
});
</script>
The -10 value, I have been playing around with this - positive values, negative values. But nothing seems to be happening. At the moment you can see the 'stickytop' wrapper, but previously I had it hidden - thinking the script will call it into view.
Can anyone help me with where I am going wrong? Does anyone have any code to help me out?
Many thanks :-)

 

Can't give you the solution but I've got to ask why are you doing this? It doesn't have good usability and if you look at the example site on tablet/phone it doesn't even work.

 

Like all these pretty things they rarely add value. Just like huuuuge hero images.

 

Leave it off your site and focus on the content.

Edited by fisicx

It doesn't have good usability

 

Could you explain why? Sticky menus are widely used and I, personally, never heard of anyone having problems with them when properly done (not taking up half the screen or anything)

 

Also, smashing magazine has this article about it, which suggests the opposite:

https://www.smashingmagazine.com/2012/09/sticky-menus-are-quicker-to-navigate/

Edited by rhubarblover

Because they often change and move.

 

If you have a sticky menu that doesn't change as the user scrolls down it's less intrusive and it can work. well. But if you have a big header that shrinks and animate when you scroll down it's jarring.

 

The other problem is they don't transfer well to a small screen. You often end up with awkward tiny thing that is difficult for fat thumbs to use. Even worse it where you just get a logo and a hamburger.

 

So use a sticky if it fits and doesn't animate and it works on a small screen. If you can't make it work on all devices then it's probably best to avoid.

 

It's the mobile thing that should drive your design.

Because they often change and move.

 

If you have a sticky menu that doesn't change as the user scrolls down it's less intrusive and it can work. well. But if you have a big header that shrinks and animate when you scroll down it's jarring.

 

The other problem is they don't transfer well to a small screen. You often end up with awkward tiny thing that is difficult for fat thumbs to use. Even worse it where you just get a logo and a hamburger.

 

So use a sticky if it fits and doesn't animate and it works on a small screen. If you can't make it work on all devices then it's probably best to avoid.

 

It's the mobile thing that should drive your design.

 

We do this a lot and really if done right it isn't that jarring. If it stayed the same height then it would be intrusive, there's one thing that users hate and that is really tall sticky headers.

Also a logo and hamburger menu on mobile is fine, if you have many menu items there is not much else you can do. We've tested it a lot and found if you add the text menu to the side it helps a little for those who are unsure of what the hamburgers mean.

 

The homepage of my former employer for example is not jarring at all http://wasabiweb.se/ and there's not much else we could do on small screens other than show a hamburger icon. If you have only 2-3 menu items then that's a different kettle of fish altogether.

 

We tend to stick with the same condensed header on smaller viewports, but you get around the scrolling problem on touch devices (iOS in particular) by passing a callback to requestAnimationFrame that tests the position of the viewport in relation to the document to determine if the user has recently scrolled, what direction and the current position.

Edited by rbrtsmith

Yours is a really good example of how to do a sticky header. The pole dancer site wasn't.

 

So as with all things webby - there is no one way to do things. But big animations aren't good, small subtle changes are.

The worst thing I found on the pole dancing link was the scroll performance was janky, and the movement feels very unnatural, I'm not a fan of anything that hijacks the scroll.

After mulling over the whole menu thing I recalled a long discussion I had on another forum many years ago.

 

If the marketing is done right and the site is properly designed the main menu shouldn't be needed.

 

Suppose I refurbish widgets. My marketing should land prospective customers on my widget refurbishment page. All the information they need should be on that page along with testimonials, related services and the important call to action. There would be no need to click on anything in the main menu.

 

If I landed on the homepage because someone had google my name again everything should be accessible from the homepage content. No need to use the main menu.

 

This doesn't mean not to have a menu, it's just that it doesn't need to be sticky. A well designed site will lead the visitor from the main content to where they want to go next.

 

Look at Amazon, apart from the search, how many of the main menu links do you you ever use?

 

And this forum, how many of the primary links do you click on?

I actually use the menu a lot on Amazon. The sticky or not thing depends entirely on the site, content and structure - bear in mind a lot of sites are more app like now. Like Twitter for example has a sticky header on large screens. There's examples of huge tech companies and some go sticky and some don't.

They A/B test these things rather than just discuss and assume and using those tests determine what the best approach is.

Edited by rbrtsmith

...

My marketing should land prospective customers on my widget refurbishment page. All the information they need should be on that page along with testimonials, related services and the important call to action. There would be no need to click on anything in the main menu.

...

 

I can see lots of reasons to acces the menu even if you are so extremely lucky that all your visitors land exactly on the page you want every time.

What happens if they want to contact you? You dont want them yo navigate to your contact page?

What If they want to read your shipping terms? Read about firms fair trade policy? Download your app?

You really want to stuff all that content into every page just because you refuse to have an easy accessible navigation?

 

If it is a webshop what makes you even remotely sure that your users land on the exact product or category page and ONLY want to buy a single item or items from one category only? Woudn't you want the user to order items from as many categories as possible?

 

I don't understand why you oppose sticky menus so much fisicx. There is a reason they are so popular.

Web pages on mobiles tend to be very long and it is NOT user friendly to have the user scroll/swipe forever to get to the top so either a sticky menu or a link to the top is almost always a plus for the user experience.

What happens if they want to contact you? You dont want them yo navigate to your contact page?

What If they want to read your shipping terms? Read about firms fair trade policy? Download your app?

You link from the content.

 

I'm not saying any sort of menu is a bad thing and I'm not against sticky anything. I'm just suggesting you can design a site so the visitor doesn't need to use the primary menu.

 

As to mobiles, if you use the hamburger menu (even with a menu caption) it's poor usability - the visitor has to click to even discover what options there are. But if you have a link to the T&C at the point on the page where it is applicable then it is more useful. And adding your contact details to the page (or at least the telephone number and email plus a link to the contact page) is good usability. You could add it to the bottom of the blurb with a 'if you have any questions call us on 012345656789' message

 

It's about helping the visitor rather than just having the links at the top of the screen.

...

It's about helping the visitor...

Noone disagrees with that.

But you can not convince me that an easy accessible global meu is a less helpful than inline links placed where you think the user wants them.

Food for thought:

 

click-heatmap.jpg

 

 

This is what I like to see - actual test data rather than debate based on assumptions. One thing I should add is that sticky menus should not take up more height than necessary, normally no more than 50 pixels, which is why most of mine shrink as you scroll down the page to make them less obtrusive.

Food for thought:

Indeed, and I wouldn't expect anything different - my heatmap looks very similar. All I was suggesting is that if someone lands on a page of the site and everything they need is on the page or there are inline links and buttons they don't need the menu. I'm not saying don't have a menu.

 

If ABC Window Cleaning had the contact details on the homepage with a contact form there would be no reason to look for a Contact Us' link. Same as your site. If you had your phone number and email above the fold or a contact me button you might find more people click that than the one in nav bar.

 

My posts are just thinking out loud. I'm not saying X is right and Y is wrong. They are just suggestions and ideas.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.