Jump to content

Moving header menu below second section homepage

Recommended Posts

I was wondering if anyone can help, I have found and used this code from @tuanphan which was incredible, however I am looking to put the navigation bar below the 'second section' of the homepage (while keeping the dynamic and re-appear on scroll back properties) 

Is this possible?

 

this is the code found from @tuanphan

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://d1j8mu9lowy9zf.cloudfront.net/twcsl/0.2.2/twcsl.js"></script>
<script>
document.addEventListener("DOMContentLoaded",function() {
    const header = document.getElementById('header');
    const firstSection = document.querySelector('.page-section:first-child');
    firstSection.after(header);
});

</script>
<style>

@media screen and (min-width: 768px) {
#header {
  position: sticky;
  top: 0;
  display: none;
}
main .page-section:first-child + #header {
  display: block;
}
main .page-section:first-child {
  min-height: calc(100vh - 93px)!important;
}
}

</style>

Edited by BareCreative
Link to comment
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I have tried using this change to the code - (replacing 'first-child to 'nth-child(2) 

Which has worked but has caused the section section to have strange spacing and also lost the dynamic movement within the header navigation

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://d1j8mu9lowy9zf.cloudfront.net/twcsl/0.2.2/twcsl.js"></script>
<script>
document.addEventListener("DOMContentLoaded",function() {
    const header = document.getElementById('header');
    const firstSection = document.querySelector('.page-section:nth-child(2)');
    firstSection.after(header);
});

</script>
<style>

@media screen and (min-width: 768px) {
#header {
  position: sticky;
  top: 0;
  display: none;
}
main .page-section:nth-child(2) + #header {
  display: block;
}
main .page-section:nth-child(2) {
  min-height: calc(100vh - 93px)!important;
}
}

</style>

Link to comment

managed to solve this through - (code below) - anyone see any issues with this?

ALSO

Could anyone help with being able to enable 'scroll back' as everytime i enable it through the pre-header settings - it causes the code to break?

 

 

<style>
@media screen and (min-width: 768px) {
#header {
  position: sticky;
  top: 0;
  display: none;
  z-index: 10000;
}
main .page-section:nth-child(2) + #header {
  display: block;
}
</style>

<script> 
document.addEventListener("DOMContentLoaded",function() {
    const header = document.getElementById('header');
    const firstSection = document.querySelector('.page-section:nth-child(2)');
    firstSection.after(header);
});
</script>

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.