0
Good afternoon guys, my problem is this:
When I open the mobile menu of my site, the scroll height remains giant (the full page size). And I can’t add position 'Fixed' in the body because my menu has a height greater than 100vh (the menu has scroll Y).
What I need is the following: when opening the menu, limit the body scroll only to the end of the menu div. That way I could keep the scroll to view the entire menu, but I wouldn’t be stuck with a giant scroll for nothing.
- -> when you open the menu, add the "open" class - OK
- -> with the menu open, set the body height equal to the total menu height - OK
- -> limit the scroll to the end of the menu height (not to be with a giant scroll) - pending
I’m doing with jquery
my website: www.barradatijuca.com.br
I searched a lot about a solution to my problem and did not find... I even tried to use the plugin scrolltofixed, but it didn’t work... Thank you for your attention
If you add a
position: fixed
in the menu, make it occupy 100% of the width and height of the screen and add an overflow:Hidden in it the menu will occupy 100% of the screen, and the content within it will be "scrollable". In that case it would open by superimposing the body.– Dian Carlos
Didn’t work buddy, if I put the menu with position Fixed, it won’t roll down and some items won’t appear. Thanks anyway.
– Hugo Deveza
Opá! I got confused, in fact the menu should receive one
overflow: auto
, then the content that does not appear will have scroll.– Dian Carlos
Why don’t you make one
min-height:296px;
in his.menu-mobile.open{}
and takes theheight: 100%
. It’s a more functional solution to your problem, I believe.– Ivan Ferrer
To remove the scroll just use media queries:
@media (max-height:680px) { body { overflow-y: hidden; } }
. Worse than removing scroll to hell from your menu, it’s hiding user content, I do not recommend it.– Ivan Ferrer
Ladies and gentlemen. I appreciate the attempt, but no method has worked to solve my problem. @Ivanferrer even removing the 100% and putting min-height in the menu, the body scroll continues.
– Hugo Deveza
The "n" ways to do this @Hugodeveza, the problem is that you haven’t published any code in the question, so it’s hard to publish an answer based only on the address of the site you’re producing. I’ll even publish a reply that could be applied to your system, but I don’t think you’ll know how to use it.
– Ivan Ferrer