0

[solved] Anybody having trouble with this code? Can you still see the close button after opening the menu?

Hello, I was wondering if any of you have trouble with this code. When you open the menu, can you still see the close button? It isn't seen when I run it in developer tools (inspect feature) in chrome in my PC. But works on my phone. But I'm still not sure about other phones. Please report if it doesn't work. Thanks in advance : ) https://code.sololearn.com/WQ383vPhQOMw/?ref=app

15th Apr 2020, 7:01 AM
Evans
Evans - avatar
17 Respostas
+ 4
As I already said to you in another question related to this code, I can't see the close button on my phone... I was giving a quick fix (but without knowing if it could break yout design in another device/viewport combinations ^^) I suspect your footer to be the cause of the viewport growing (and needs for scroll horizontal AND vertical), as when menu is open viewport is scaled by approximativelly 2 (probably because you move your footer down and to the right (rather than shrink it or set 'hidden' on a good selected parent css property overflow)...
16th Apr 2020, 2:13 AM
visph
visph - avatar
+ 2
Mmm... the padding: wasn't it what I suggested to remove in my post on your other thread few days ago? ;)
16th Apr 2020, 7:00 AM
visph
visph - avatar
+ 1
Well, I don't see it my phone. However there are some general issues with the code. First of all you shouldn't use JavaScript for styling. You can create a extra CSS selector and toggle a class name with JavaScript to activate and deactivate it. If you do that you can go into the Firefox dev tools (I think they are the best out there currently) and write your CSS into the page directly. There you can also test different smartphone layouts and see what works best. Later you can copy the CSS to your actual code and then you're done :)
15th Apr 2020, 7:14 AM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 1
You can use JavaScript to style elements but I recommend to do this by toggling a class name and doing the actual styling in a CSS file. Otherwise you will eventually bloat your whole JavaScript with style instructions and debugging the style will become a nightmare. Also I'd do as much as possible in CSS because it's generally cleaner and more efficient.
15th Apr 2020, 1:08 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 1
Aaron Eberhardt, one final thing please. In your first post did you mean you don't see the close button or do you see it? It wasn't clear to me.
15th Apr 2020, 3:30 PM
Evans
Evans - avatar
+ 1
Evans yes I can't see the close button. I guess it's because you use absolute units (px) instead of relative units like vw, vh and %. There are many different screen sizes so it's important to use relative units so your layout fits to every screen.
15th Apr 2020, 6:29 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 1
The close button is pushed over to the rigjt you need to reduce the width of the navbar
16th Apr 2020, 2:48 AM
Joshua Flynn
Joshua Flynn - avatar
+ 1
In here i have made the width and margin changes that make it work the way i believe you are wanting. https://code.sololearn.com/WKywuRPlmexN/?ref=app
16th Apr 2020, 2:55 AM
Joshua Flynn
Joshua Flynn - avatar
+ 1
Better, as we (at least me) could see the close button and no scroll is implied... but I don't know if that fits your design expect: the opened menu doesn't cover the full screen width ;)
16th Apr 2020, 2:58 AM
visph
visph - avatar
+ 1
Well, thanks everybody. But I think padding on the sidenav is the cause (though I also think the footer rescaling the viewport as suggested by visph ). Earlier I had a problem with header and after removing paddings, it workedšŸ˜ƒ
16th Apr 2020, 6:57 AM
Evans
Evans - avatar
+ 1
I guess that the sidenav "push" the footer when it is opened... (but I've not investigate further)
16th Apr 2020, 7:36 AM
visph
visph - avatar
0
Thanks Aaron Eberhardt, but why do you say not to change css with js? Isn't it more dynamic?
15th Apr 2020, 11:16 AM
Evans
Evans - avatar
0
Maybe I'll have to replace padding with margin. And I checked but how is the footer connected with sidenav?
16th Apr 2020, 7:26 AM
Evans
Evans - avatar
0
Hey thanks that was a valuable clue šŸ˜ƒ
16th Apr 2020, 7:38 AM
Evans
Evans - avatar
0
Delete the meta device width it's effect on it ! - make menu width with 99 vw 99vh ;
17th Apr 2020, 1:15 AM
Omar Khalil Bakhsh
Omar Khalil Bakhsh - avatar
0
visph, Joshua Flynn, and everyone, it's fixed. I used JavaScript to get screen width, converted to string and used that value in px: mySidenav.width = screen.width.toString() + "px"; ...But didn't figure out what was wrong with 100% widthšŸ˜€
19th Apr 2020, 8:45 AM
Evans
Evans - avatar
- 2
your cache on your browser may need to be refreshed
19th Apr 2020, 1:06 AM
David Paredes
David Paredes - avatar