- This topic has 32 replies, 4 voices, and was last updated 1 year, 3 months ago by David.
-
AuthorPosts
-
February 19, 2019 at 7:28 am #814675Adam
Hey Tom and Generate Press Team,
I’m trying to add a subtle transition to the mobile menu so that it appear to drop down. I used the code you suggested on this post: Ease-in transition for mobile “Hamburger” dropdown menu
@media (max-width: 768px) { .main-navigation .main-nav > ul { display: block; max-height: 0; overflow: hidden; transition: max-height 100ms ease-in-out; } .main-navigation.toggled .main-nav > ul { max-height: 1000px; transition: max-height 400ms ease-in-out; } }
But I have 3 issues:
1. My mobile menu is vertical and centered, yet when closing for some reason this transition makes it briefly appear horizontally, which looks really glitchy. I’ve confirmed that when I delete that code the problem goes away (but obviously I’m left without any transition effect).
2. I can’t figure out how to add the same effect to sub-menu items. I tried duplicating the above code and adding another ul or an li but to no avail.
3. I would love for the body to drop down when the mobile menu expands. On my pages the header has a slanted bottom look (achieved through Elementor with a Shape Divider on the top section just below the header), and I would love for the mobile menu to expand down (with the transition) and push the body down so that the menu has the same tilted shap divider and doesn’t cover up any of the body content. Is that possible?
Thanks!
AdamFebruary 19, 2019 at 3:02 pm #814960TomLead DeveloperLead DeveloperHey Adam,
Try this as your CSS:
@media (max-width: 768px) { .main-navigation .main-nav > ul { display: block; max-height: 0; overflow: hidden; transition: max-height 100ms ease-in-out; } .main-navigation.toggled .main-nav > ul { max-height: 1000px; transition: max-height 400ms ease-in-out; } .main-navigation .main-nav li { float: none; clear: both; display: block!important; } .menu-item-has-children .dropdown-menu-toggle { padding-left: 20px; } .main-navigation .main-nav .sub-menu { display: block; max-height: 0; overflow: hidden; transition: max-height 100ms ease-in-out; } .main-navigation .main-nav .sub-menu.toggled-on { max-height: 1000px; transition: max-height 400ms ease-in-out; } .both-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav>ul { position: relative; } }
Let me know π
February 19, 2019 at 3:14 pm #814967AdamHey Tom, that worked great for most everything! It just seems to be lacking any ease/transition (up) when closing the menu. Is that possible?
Thanks!
AdamFebruary 19, 2019 at 5:49 pm #815032TomLead DeveloperLead DeveloperYou’ll want to replace
100ms
in your code with something higher πFebruary 19, 2019 at 6:10 pm #815048AdamThanks Tom! Between the quality of the theme and the quality of your support, I don’t know why anyone else uses any other theme. π
February 19, 2019 at 6:16 pm #815054TomLead DeveloperLead DeveloperThank you! Glad I could help π
March 7, 2019 at 12:02 pm #832078AdamHey Tom,
1. I just realized that when I expand the sub-menu in my mobile menu, and then collapse the entire mobile menu without first collapsing the sub-menu, the sub-menu remains visible in a really ugly way. I must have done something wrong with the code I added to target the sub-menu. Problem happens on both mobile menu and sticky mobile menu.
Picture of the problem (left is how it looks if I collapse the sub-menu before collapsing the main menu, right if I don’t): https://www.dropbox.com/s/yithsri0px6pus2/Menu%20Problem.png?dl=0
2. Also (less important and maybe related), when I expand the mobile sub-menu (and main menu) it has a transition, but when I collapse it there is no transition (main menu does). Would love it to have the same transition when collapsing.
Thanks in advance,
AdamHere is my code for the mobile menu:
/* Mobile Menu Slide Effect */ .main-navigation.toggled .main-nav li { text-align: center !important; } .main-navigation.toggled .menu-item-has-children .dropdown-menu-toggle { float: none; } .main-navigation .main-nav > ul { display: block; max-height: 0; overflow: hidden; transition: max-height 400ms ease-in-out; } .main-navigation.toggled .main-nav > ul { max-height: 1000px; transition: max-height 400ms ease-in-out; } .main-navigation .main-nav li { float: none; clear: both; display: block!important; } .menu-item-has-children .dropdown-menu-toggle { padding-left: 20px; } .main-navigation .main-nav .sub-menu { display: block; max-height: 0; overflow: hidden; transition: max-height 400ms ease-in-out; } .main-navigation .main-nav .sub-menu.toggled-on { max-height: 1000px; transition: max-height 400ms ease-in-out; } .both-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav>ul { position: relative; }
March 7, 2019 at 3:56 pm #832271TomLead DeveloperLead DeveloperHey Adam,
I’m not sure I fully understand. What makes the screenshot on the right happen?
Any chance you can re-open up your dev site so I can take a look?
March 7, 2019 at 4:38 pm #832309AdamHey Tom,
Load on mobile to trigger mobile menu > Open mobile menu > click on About Us to expand sub-menu > click ‘X’ to close entire mobile menu (without first closing sub-menu).
Sub-menu should remain visible (and off to the left) over content even though main menu is collapsed. If you want I can make a short screencast – let me know.
Best,
AdamMarch 7, 2019 at 4:51 pm #832318TomLead DeveloperLead DeveloperTry adding this CSS:
@media (max-width: 768px) { .main-navigation:not(.toggled) .toggled-on { position: relative; width: 100% !important; text-align: center; } }
March 7, 2019 at 4:55 pm #832322AdamThat did it! Thanks Tom!
And can you tell from my code why the sub-menu closes without any transition?
Adam
March 7, 2019 at 5:03 pm #832328TomLead DeveloperLead DeveloperWhat if you add this?:
.main-navigation.toggled .main-nav ul ul { position: relative; left: auto!important; height: auto; opacity: 1; visibility: visible; }
March 7, 2019 at 5:05 pm #832330AdamThat did it! I got a couple of beautiful menus on our site now! Thanks as always Tom! π
March 7, 2019 at 5:06 pm #832332TomLead DeveloperLead DeveloperYou’re welcome π
September 26, 2020 at 10:00 pm #1460508JeanHey Tom, thanks for this — this gives me a nice little transition on opening my mobile submenus, but the submenus still snap shut, and more importantly the whole menu still snaps open and closed. Any chance you can help me smooth those things out, or at least the open/close of the main mobile menu?
I’m working at https://rdusdev3.wpengine.com/ (although we might go live within a day or two at http://rainforestfoundation.org/ )
And here’s what I have so far:
@media (max-width: 768px) { .main-navigation .main-nav > ul { display: block; max-height: 0; overflow: hidden; transition: max-height 1000ms ease-in-out; } .main-navigation.toggled .main-nav > ul { max-height: 1000px; transition: max-height 1000ms ease-in-out; } .main-navigation .main-nav li { float: none; clear: both; display: block!important; } .menu-item-has-children .dropdown-menu-toggle { padding-left: 20px; } .main-navigation .main-nav .sub-menu { display: block; max-height: 0; overflow: hidden; transition: max-height 1000ms ease-in-out; } .main-navigation .main-nav .sub-menu.toggled-on { max-height: 1000px; transition: max-height 1000ms ease-in-out; } .both-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav>ul { position: relative; } }
Any help would be greatly appreciated — thanks so much!
-
AuthorPosts
- You must be logged in to reply to this topic.