Mobile navigation

This is what i see on your live site.

The search menu looks really odd and I don’t see a nav anywhere apart from the usual one.

Remember when we talked about magic numbers (in almost every thread)? Then explain what this is doing.


bottom: 565px;

As seen here:

.swrapper {
    background-image: linear-gradient(to bottom right, #201, #a0f);
    width: 100%;
    height: 35px;
    position: fixed;
    bottom: 565px;
    left: 0px;
    z-index: 15000;
    border: none;
    display: flex;
}

That’s of no use to anyone and devices or windows less that 565px tall get nothing as the element will be out the top of the viewport. Use logical numbers that make sense.

Also the menu just sits on content and obscures it. It should probably be a position:sticky element rather than fixed and then only gets sticky when the page scrolls.

3 Likes

@PaulOB I have changed from that and want to go with this instead :

But when trying to put it on my blog yesterday, it didn’t go well. Here’s the CodePen

Remember when we talked about magic numbers (in almost every thread)?

Yes I do remember. But like I said in my message to you, it is hard to keep everything in mind while going through all this. So much to remember, difficult to keep track of it all.

Which is exactly why you were strongly encouraged to start over and use correct techniques from the beginning.

You would benefit greatly by completing a beginners course in HTML and CSS. Trust me, you’re not too advanced for it.

3 Likes

I guess it’s impossible to do it all without courses. But I’ve gotten far without, with help of course. I’m just interested in knowing how to build these, such as the side menu. I mean, I find it fascinating when I watch tutorials on it on YouTube, and see it elsewhere.

You are going about this the wrong way.

There’s no need to create a new side menu you just restyle the existing horizontal one for smaller screen. You then just need a hamburger menu toggle to show and hide the nav as required.

The navigation is the same html and you just move it to the side for smaller screen. I’ll try and put up a small demo tomorrow using your nav html

2 Likes

@PaulOB yeah I realize that. Ok I’d appreciate that, thanks.

There’s no need to create a new side menu you just restyle the existing horizontal one for smaller screen. You then just need a hamburger menu toggle to show and hide the nav as required.

The navigation is the same html and you just move it to the side for smaller screen.

I understand. Seems easier said than done. Is what I want to try and do, but as you say I have it all going the wrong way. Could you please also put up a demo for putting up the search box up top for my current navigation? I made it out on CodePen, how it would look like on phone…

I’ve put up a rough demo here of your header with a sticky search bar added and then a mobile nav appears at smaller screens.

I have not been that careful with the styling but just wanted to show the implementation.

Notice that the nav has been pulled out of the header div to make it easier to reposition for mobile. I moved the search input css to the end of the css panel along with the new css rules for the hamburger and menu re-positioning code.

A hamburger menu appears at smaller screens and is linked to the js which toggles a class to open the menu.

Here is a barebones demo of a similar hamburger and menu.

3 Likes

@PaulOB thank you. Looks great.

Is it possible to change the hamburger icon to the one I had, which was this ?

What is that ?

No one will know what it is?

You can change the hamburger to whatever you want it to look like. Just adjust the css for #toggle. However if you change it just to that half arrow then I guess no one will ever click it as they won’t know what it’s for unless you keep the menu text in place.

Also note that is far too small for someone to hit with their thumb or fingers and a menu should be the most accessible thing on the page otherwise all bets are off. You would need to ensure that the target area is wide enough for touch which can be achieved by ensuring there is some padding around the arrow.

2 Likes

@PaulOB so that would be in place of the hamburger / X icon.

You can change the hamburger to whatever you want it to look like. Just adjust the css for #toggle. However if you change it just to that half arrow then I guess no one will ever click it as they won’t know what it’s for unless you keep the menu text in place.

Yeah, good point. Maybe I should just leave it as is then.

Also note that is far too small for someone to hit with their thumb or fingers and a menu should be the most accessible thing on the page otherwise all bets are off. You would need to ensure that the target area is wide enough for touch which can be achieved by ensuring there is some padding around the arrow.

Could make it larger w some padding. Or if larger, just without as it would be big enough to use with thumbs, other fingers.

The icon can remain small but the ‘hit area’ can be larger by using padding around the icon.

1 Like

Yes just place your icon inside the button called #toggle and remove the relevant styling from it. You won’t need the :before and :after rules but of course you lose the hamburger animation from hamburger to close.

Remember a hamburger is now the standard icon for opening menus and used everywhere. Substitute the icon at your own risk.

2 Likes

@PaulOB where you have the repeating text going down the page, is that for the mobile view also?

That is to show you how the sticky search bar works on desktop as it will stick to the top of the screen. On mobile the search bar is at the top of the navigation screen instead.

1 Like

Ok thought that was part of the mobile.

No it was just to show the sticky search bar effect because you wouldn’t have noticed it otherwise as it only sticks to the top when you scroll. You can of course delete that text and replace it with your actual content.

1 Like

Ok I seem to be getting carried away by the new nav mobile menu. I am seeing this when putting it on my live page

I can see it on page resize though, which is great. But I really don’t need this 2nd horizontal menu.

Why have you got 2 menus?

2 Likes