~ / archivo / stackoverflow / 44373869
Change fixed position on click
-
I'm going to try make it clear:
I have a mobile menu with media queries and a header fixed on mobile. The situation is the customer want the header (with logo) fixed on top, but when I try to expand the menu item (like Menu > SubMenu > Submenu) it expand vertically but I can not scroll to bottom (the page is scrolling behind it, but not the menu). So I figured out how to make it work: When the site loads the header is fixed, but when someone tries to use the top menu, they must click on the hamburger menu and (this what I want you to help me), and when they click on the hamburger menu the header should pass from
position:fixedtoposition:static, just then the mobile menu will scroll down as I want.Here the site: http://centro.anden.pe
Any ideas? Thank you in advance.
- J. Allan 2017-06-05 17:12 Would you mind giving a current code example? What does your layout look like?
- Robhert Pimentel 2017-06-05 17:15 In fact I was trying to put the site online and making a gif (to come).
- j08691 2017-06-05 17:20 Please add meaningful code and a problem description here. Don't just link to the site that needs fixing - otherwise, this question will lose any value to future visitors once the problem is solved or if the site you're linking to is inaccessible. Posting a Minimal, Complete, and Verifiable example (MCVE) that demonstrates your problem would help you get better answers. For more info, see Something on my web site doesn't work. Can I just paste a link to it? Thanks!
- J. Allan 2017-06-05 17:25 If you put
position: staticon the nav after you fixed it to the top of the screen, it will no longer be visible. Theposition:staticwill put it in the page where it used to be, and you won't be able to see it anymore.
-
You didn't attached code, but here's a functional example of that idea (click on the hamburguer menu)
$(document).ready(function() { $("#hamburguer_menu").on("click", function() { $("#change-div-if-click").css("background-color", "yellow") $("#change-div-if-click").css("position", "static") alert ('now the position is static') }); });#hamburguer_menu { height: 60px; width: 60px; background-color: yellow; } #change-div-if-click { background-color: teal; }<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <body> <div id="hamburguer_menu"> <img src="https://www.iconfinder.com/data/icons/tupix-1/30/list-512.png" / height="60px" width="60px"> </div> <div id="change-div-if-click"> <p>Change when clicked</p> </div> </body> </html>- Robhert Pimentel 2017-06-05 18:00 Thank you Miguel. I'm going to test it right now. I'll let you know how it's going.