Jump to content

[Share] Second button on Header

Recommended Posts

You can use this tip to add second button to Header

#1. With Personal Plan (doesn't support Code Injection)

My idea is turn last two navigation items to button style.

Use this code to Website Tools > Custom CSS

nav {
    align-items: center;
}
div.header-nav-item:last-child>a {
    background-color: #f1f;
    color: white !important;
    padding-left: 20px;
    padding-right: 20px;
    padding-top: 10px;
    padding-bottom: 10px;
}
div.header-nav-item:nth-last-child(2)>a {
    background-color: #ff2;
    color: blue !important;
    padding-left: 20px;
    padding-right: 20px;
    padding-top: 10px;
    padding-bottom: 10px;
}

image.thumb.png.578ecfed53b43c2772ffe2dd7c420fee.png

with Mobile, use this CSS code

.header-menu-nav-wrapper>div.header-menu-nav-item:last-child>a {
    background-color: #f1f;
    color: white !important;
    padding-left: 20px;
    padding-right: 20px;
    padding-top: 10px;
    padding-bottom: 10px;
    display: inline-block;
}
.header-menu-nav-wrapper>div.header-menu-nav-item:nth-last-child(2)>a {
    background-color: #ff2;
    color: blue !important;
    padding-left: 20px;
    padding-right: 20px;
    padding-top: 10px;
    padding-bottom: 10px;
    display: inline-block;
}

image.png.76da7ef1349d96c6627bff9dd7ac3239.png

#2. With Business Plan/higher

You can use #1, or use this following code to add button next to current header button

You can add code to Website Tools > Code Injection > Footer

<a class="btn btn--border theme-btn--primary-inverse sqs-button-element--primary second-button" href="https://google.com">Contact</a>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
  $(document).ready(function(){
    $('a.second-button').insertAfter('a.btn');
});
</script>

and this code to Custom CSS box

a.second-button {
    display: none;
}
header#header a.second-button {
    background-color: black !important;
    color: #f1f !important;
    display: inline-block !important;
}

image.thumb.png.3dfae436fb562cdc0fae3704cfb6c419.png

image.png.82aec769ff599228d47c92c4f5d42cac.png

To make button appear before current Header button, just change this to insertBefore

image.png.c670288399481d75da5851b71b3a7538.png

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
  • 4 weeks later...
  • Replies 2
  • Views 2.3k
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 month later...

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.