This is my project I would like to share with you: https://codepen.io/liukangaroo/pen/wvKgZNM
I have no idea how to display navbar on top for mobile browsers (using media query) without mindlessly copy-pasting some googled code. Temporarily I’ve disabled it by display: none; just to pass the test.
Can somebody ELI5 how to do it? I must admit that I have some trouble understanding the concept of media query
The way I would do it is using Flexbox. When the page is on a large screen, just have the default flex-direction. When the page is on a smaller screen, set the flex-direction for column.
Try adding back the CSS you did write so we can see what you have tried.
Without posting code.
In the media query add a selector for the
#navwrap element. Remove the float and give it 100% width to make it take up the full width of the page.
Give it a height that is less than the content and set the overflow-x to auto. This will give you a scroll box for the links.
Remove the negative top margin and use
top: 0 instead (just a better way to do the positioning).
Fix the CSS for the
navbar element (height, and any different positioning you want, etc.).
Look at some solutions for making the links land correctly on the sections again, as they will not do so after the changes to the nav.
Hi @labla1, something to revisit;
- Don’t use
<br> to force line breaks. Nest multi-line
<code> snippets in
<pre> </pre> tags in HTML to preserve whitespace and line breaks. Or you could do
in CSS and skip the
<pre> tag in HTML.
Hi, I haven’t had much time lately to work on it but from what I see your advice is brilliant. I’ll post final version when it’s done.
@Roma thanks, I didn’t know that tag existed Maybe you should add one lesson mentioning it to the curriculum? Seems pretty neat to avoid so much repetition I did.
Here is the final version: https://codepen.io/liukangaroo/pen/wvKdpLw
Everything works as intended.
Made nav scroll hidden when @media starts to work just for a better look
Thanks again, you guys are great!
I know the default scrollbar can be a bit ugly but without it, the user really doesn’t know that the area is scrollable. Remember the user may only see the page at the small screen size and not know anything about the page other then what they first see. So from a UX perspective, it really isn’t a good idea to hide it.
You can look into customizing it although cross-browser support isn’t great.
Oh and here is the link to your current page, the link you posted is dead.