Toggle menu

Hi guys how can i get the menu icon all to the right https://codepen.io/Boeroe/pen/xxMgrxz
Boeroe
CodePen
xxMgrxz
...
16 Replies
MarkBoots
MarkBoots7mo ago
for the open and closing of the navbar. don't do it with the left position just set the left to 0 and use translate to move it on/off screen
Boeroe
Boeroe7mo ago
I fixed it with left to -110 but you dont recommand that?
MarkBoots
MarkBoots7mo ago
No description
MarkBoots
MarkBoots7mo ago
with translate: -100% 0 it will always be the full width of itself that it shifts to the left. so no magic number needed
Boeroe
Boeroe7mo ago
Yes also working with that i see
MarkBoots
MarkBoots7mo ago
and instead of using .navbar, i would do it on the <nav> itself. that way there won't be an empty element still in your header. (that is the reason why the icon is not positioned fully to the right so this inside your mediaquery
nav {
position: absolute;
top: 100%;
left: 0%;
width: 100%;
margin: 0;
translate: -100% 0;
transition: translate .25s ease;
transition-delay: .25s;
}
nav.active {
translate: 0;
transition-delay: 0s;
}
.navbar {
padding: 1rem 4%;
background: red;
box-shadow: 0 .5rem 1rem rgba (0, 0, 0, 2);
flex-direction: column;
}
nav {
position: absolute;
top: 100%;
left: 0%;
width: 100%;
margin: 0;
translate: -100% 0;
transition: translate .25s ease;
transition-delay: .25s;
}
nav.active {
translate: 0;
transition-delay: 0s;
}
.navbar {
padding: 1rem 4%;
background: red;
box-shadow: 0 .5rem 1rem rgba (0, 0, 0, 2);
flex-direction: column;
}
you'll need to adjust the queryselector in the js from .navbar to nav
let navbar = document.querySelector('nav');
let navbar = document.querySelector('nav');
Boeroe
Boeroe7mo ago
Boeroe
Boeroe7mo ago
When I copy that I’m running in to those errors Its not going to the right, the menu is not working. And as soon as you make the screen smaller it suddenly comes into view and is gone again
MarkBoots
MarkBoots7mo ago
think you didnt change the js. also declare the properties you want to transition. so transition: translate .25s otherwise, update your pen so i can check
Boeroe
Boeroe7mo ago
It is working, the only problem im still runing into is that if u make the screen smaller its coming up and its gone again as u can see in the recording at the very beginning https://codepen.io/Boeroe/pen/xxMgrxz
Boeroe
CodePen
xxMgrxz
...
MarkBoots
MarkBoots7mo ago
personally i would'n mind it too much. users don't just change window sizes during a visit. otherwhise you can use an evenlistener on window resize, to temporarily turn off the animation
Boeroe
Boeroe7mo ago
Its just anoying me haha Its as soon as you come at the 768px U have an example of that?
MarkBoots
MarkBoots7mo ago
for example
window.addEventListener("resize", ()=>{
navbar.classList.add("no-transition");
setTimeout(()=>{
navbar.classList.remove("no-transition");
},500)
});
window.addEventListener("resize", ()=>{
navbar.classList.add("no-transition");
setTimeout(()=>{
navbar.classList.remove("no-transition");
},500)
});
and in css add an extra
nav.no-transition{ transition: unset }

nav.no-transition{ transition: unset }

Boeroe
Boeroe7mo ago
Still coming when making the screen smaller
MarkBoots
MarkBoots7mo ago
i updated your pen. it should work. i also close the menu as soon as the window resizes so it wont stay open even if the screensize is large https://codepen.io/MarkBoots/pen/oNmWgmb
Boeroe
Boeroe7mo ago
Yup it worked, its gone. Thank you so much!
Want results from more Discord servers?
Add your server
More Posts
django rest frameworki have a question i want to give user to authinticate itself using 2 ways my social platforms like gWhy do we use Netlify/other sites to host framework written apps, instead of just using Github PagesTitle, I'm curious and haven't found a solid answer yet when searching online. I'd like to know why Side bar elements responsiveI am wondering what should be my design for side bar which would have a toggle funcationality for Code review - Stats preview card componentGuys, I would like you to give your opinion on the best way I should have used to build this componeSlide-in animation snapping when opening the navigation drawer in mobile viewI am trying to clone the sidebar navigation from this website https://m3.material.io/ , How it is i18n while keeping path /en /frSo I want to use i18n for a portfolio website I have because I currently just have all my files duplTriggering an animation based on scroll positionHi there, I'm working on a website, and I've been wanting to recreate the following image. Not the What are the best practices for the number of srcset items for a dynamically sized image?I have the ability using server side rendering to render as many different source images as necessarStyling inputs, and lining up multiple list itemsHi all, Last bit of my first svelte app and I'm a happy chap! I'm hoping the sandbox works and letTrying to add a checkbox that also line-throughs my list item when completed:trueNot sure how much code you need, I've console.log("test"); which worked, and console.log({todos}); a