- This topic has 27 replies, 4 voices, and was last updated 4 years, 10 months ago by
Leo.
-
AuthorPosts
-
January 21, 2021 at 11:19 am #1628274
Charbel
Hello Team,
Could you please advise how to center the text between the Hamburger icon on the left and the Search Icon on the right for mobile devices (Black Menu).
Here is my site: https://charbelnemnom.com
Many Thanks!
-CharbelJanuary 21, 2021 at 1:47 pm #1628476Leo
StaffCustomer SupportHi there,
Unfortunately that’s not possible using the mobile menu label.
Can you add the text using the
generate_inside_mobile_menu_barwith a hook element?
https://docs.generatepress.com/article/hooks-element-overview/January 21, 2021 at 10:36 pm #1628795Charbel
Hello @Leo,
I have added a new
Hook, then I choosegenerate_inside_mobile_menu_bar, and added the text. I set the Display Rules to theEntire Site, right?
I removed the text from the primary navigationMobile Menu Label.
I can see now that the text is completely gone. It’s not showing for mobile.
Could you please advise?Thank You!
January 21, 2021 at 10:43 pm #1628797Charbel
I can see that I want to add a PHP code to use that Hook in my
functions.php.
Could you please advise what is the exact code to center the text label?The Hook name is
Mobile Menu Label Centerhttps://docs.generatepress.com/article/using-hooks/
Many Thanks @Leo!
January 22, 2021 at 12:39 am #1628865Elvin
StaffCustomer SupportHi,
generate_inside_mobile_menu_baronly works if you have Mobile header set to “on” on Appearance > Customize > Layout > Header. Else, things that are hooked on it won’t display. Your site doesn’t seem to have a Mobile Header enabled.I’m not exactly sure I fully get what layout you’re trying to achieve. Do you have any mockup images or reference sites you want to replicate? so we could have a clearer idea of what’s the best approach to this.
Let us know.
January 22, 2021 at 12:52 am #1628871Charbel
Thank You @Elvin for your support!
I want to replicate that site https://adamtheautomator.com/. If you open it on Mobile, you can see that the text label (Adam the Automator) in the Black Menu is centered.
I just enabled Mobile header “on” under Appearance > Customize > Layout > Header.
What else should I do to center my text label (Charbel Nemnom – MVP | MCT) between the Hamburger icon and the search icon on mobile?
Many Thanks!
January 22, 2021 at 1:00 am #1628877Charbel
Hello @Elvin!
After I enabled Mobile header “on” under Appearance > Customize > Layout > Header, I lost my blue logo which was above the Mobile Black Menu.
If I add the logo under Layout > Header, the logo is added within the black menu and not above the Menu.
I want the logo to be above the Menu as well.January 22, 2021 at 1:31 am #1628909Elvin
StaffCustomer SupportAfter I enabled Mobile header “on” under Appearance > Customize > Layout > Header, I lost my blue logo which was above the Mobile Black Menu.
If I add the logo under Layout > Header, the logo is added within the black menu and not above the Menu.
I want the logo to be above the Menu as well.Ah my bad. I’ve checked the actual code and
generate_inside_mobile_menu_barcan be used regardless if “mobile header” is on”. The only setting need is to be able to use this is to enable the Navigation search onAppearance > Customize > Layout > Primary Navigationwhich was mentioned here: https://docs.generatepress.com/article/generate_inside_mobile_menu_bar/But it didn’t mention about it not working if flexbox is set in Appearance > Customize > General.
https://github.com/tomusborne/generatepress/blob/e030f57d2c26991074a6868265737424dac567d0/inc/structure/navigation.php#L568Can you revert back to setting the mobile header off? Let’s try a different approach as setting the site to floats may not be preferable just to make
generate_inside_mobile_menu_barwork.Let us know.
January 22, 2021 at 1:36 am #1628918Charbel
Thank you @Elvin,
I have reverted back to setting the mobile header to OFF.
Now the blue logo is showing above the Black Menu great!
Could you please check?How can we center the text label please?
What is the best approach without setting the site to floats?January 22, 2021 at 2:59 am #1629018David
StaffCustomer SupportHi there,
try adding this CSS to center the menu label:
@media(max-width: 768px) { .main-navigation.has-menu-bar-items button.menu-toggle { display: flex; flex-grow: 1; } button.menu-toggle .gp-icon { margin-right: auto; } .menu-toggle .gp-icon+.mobile-menu { margin-left: auto; margin-right: auto; } }January 22, 2021 at 3:03 am #1629020Charbel
Thank you @David, much appreciated your support!
I have just added the CSS and cleared my cache.
I still do not see that the Menu Label text is centered.
Could you please check?
Do I still need to use the Hook mentioned before
generate_inside_mobile_menu_bar?Thank You!
January 22, 2021 at 3:04 am #1629021Charbel
The text is still aligned to left close to the Hamburger icon.
Thank You @David
January 22, 2021 at 3:09 am #1629028David
StaffCustomer SupportWell it ‘enters’ on a larger device eg. Portrait Tablet, but for Mobile there just isn’t enough room for it to align center…..
January 22, 2021 at 3:15 am #1629035Charbel
Ah thank you @David, I have just tried using different devices using Google Chrome Emulated Devices, I can see that the text is centered now. I was trying on iPhone X.
Could you please advise if the CSS code you shared will slow down the page performance?
P.S. I removed and deleted the hook
generate_inside_mobile_menu_barMany Thanks @David!
January 22, 2021 at 3:18 am #1629039David
StaffCustomer SupportNo that CSS will have no impact on performance.
CSS only becomes an issue of you’re adding 100-100’s of lines of CSS. -
AuthorPosts
- The topic ‘How to center the text label for Mobile Menu?’ is closed to new replies.