Jump to content

Mobile Overlay Menu — Responsively Centering Button with Other Elements

Recommended Posts

Site URL: http://empiricalwisdom.com

Hello! 

I am attempting to restructure the layout of the mobile overlay menu by bringing the button up beneath the other nav links (effectively making it one clean list). By default, the button is displayed at the bottom of the screen, detached from the other nav elements. 

I was able to successfully move the button up beneath the other links by using the "bottom:" property, but this option is not responsive to changes in viewport height. Thus, when the height of the screen becomes smaller, the button begins to overlap the other nav links. See pictures below for example.

I'm hoping to make this change to the mobile menu layout more responsive, so that the button maintains its even spacing from the other links and never overlaps. Would greatly appreciate your help @tuanphan !

Thanks in advance 🙂

 

The default mobile overlay menu layout (button displayed at bottom):

325722223_ScreenShot2022-01-24at10_35_10AM.thumb.png.d53b00862423b25b72a2197e8d17e7ce.png

 

The spacing I'd like to maintain responsively:

1085196834_ScreenShot2022-01-24at10_31_25AM.thumb.png.c304b17e67854cfe656ee7fc2668bcd9.png

 

The current unresponsive effect of my code when the viewport height becomes shorter:

1412399826_ScreenShot2022-01-24at10_31_41AM.thumb.png.5a23b49da976f94f64c0907cbd25d9fe.png

Link to comment
16 hours ago, tuanphan said:

Use this CSS

.header-menu-cta {
    position: relative;
    top: -100px;
}

 

Hi @tuanphan! Thanks so much for your response.  The code you provided above does help solve the overlapping, but I still can't get the button to responsively sit at even spacing with the other nav links. Is there any way to have the button act as if it were one of the main navigation links and always maintain uniform spacing with the others, even at various screen heights? I know it's in a totally separate div, so maybe it's not possible. Either way, thank you very much for all the help 🙂

Edited by tkennedy7
Link to comment
11 hours ago, tkennedy7 said:

Hi @tuanphan! Thanks so much for your response.  The code you provided above does help solve the overlapping, but I still can't get the button to responsively sit at even spacing with the other nav links. Is there any way to have the button act as if it were one of the main navigation links and always maintain uniform spacing with the others, even at various screen heights? I know it's in a totally separate div, so maybe it's not possible. Either way, thank you very much for all the help 🙂

You can add a Link Item to Navigation, then we will give the code to turn this link item to button style.

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
On 1/26/2022 at 4:34 AM, tuanphan said:

You can add a Link Item to Navigation, then we will give the code to turn this link item to button style.

@tuanphan that's an amazing idea!! Thank you. I've managed to add it as an external link, hide it on desktop view, and hide the button on the mobile menu. Can you please help me with targeting just the "Enroll" link now to add the button styling? Thanks so much again 🙂

Screen Shot 2022-01-26 at 9.19.06 AM.png

Edited by tkennedy7
Link to comment
On 1/27/2022 at 12:19 AM, tkennedy7 said:

@tuanphan that's an amazing idea!! Thank you. I've managed to add it as an external link, hide it on desktop view, and hide the button on the mobile menu. Can you please help me with targeting just the "Enroll" link now to add the button styling? Thanks so much again 🙂

Screen Shot 2022-01-26 at 9.19.06 AM.png

Add this CSS

div.container.header-menu-nav-item:last-child a {
    border: 2px solid black !important;
    background-color: black;
    color: white !important;
    display: inline-block;
    padding: 10px 20px;
    border-radius: 30px;
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
1 hour ago, tuanphan said:

Add this CSS

div.container.header-menu-nav-item:last-child a {
    border: 2px solid black !important;
    background-color: black;
    color: white !important;
    display: inline-block;
    padding: 10px 20px;
    border-radius: 30px;
}

 

Thank you so much!!! You are an absolute savior. And, I've learned a lot from you. Have a wonderful day

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.