I am trying to create a Push/slide out menu system on my site like how www.squarespace.com has, however I don't know how to do so.
My site is a Squarespace site and it uses html, json and less (you can ad .js files too): splitblog.squarespace.com/
My site.region file for navigation is:
<squarespace:navigation navigationId="mainNav" template="navigation" />
Which pulls the information from navigation.block which is this:
<nav id="main-navigation" class="main-navigation" data-content-field="navigation-mainNav">
<ul>
{.repeated section items}
<li class="{.section active} active-link{.end}{.if folderActive} active-folder{.end}">
{.folder?}
<!--FOLDER-->
<a href="{collection.fullUrl}">{collection.navigationTitle}</a>
<ul>
{.repeated section items}
<!--COLLECTION IN A FOLDER-->
{.collection?}
<li class="{.section active} active-link{.end}">
<a href="{collection.fullUrl}">
{collection.navigationTitle}
</a>
</li>
{.end}
<!--EXTERNAL LINK IN A FOLDER-->
{.section externalLink}
<li>
<a href="{url}"{.section newWindow} target="_blank"{.end}>
{title}
</a>
</li>
{.end}
{.end}
</ul>
{.or}
<!--COLLECTION-->
{.section collection}
<a href="{fullUrl}">{navigationTitle}</a>
{.end}
<!--EXTERNAL LINK-->
{.section externalLink}
<a href="{url}"{.section newWindow} target="_blank"{.end}>
{title}
</a>
{.end}
{.end}
</li>
{.end}
</ul>
</nav>
Then the .less styling for the menu is:
.main-navigation {
ul {
padding-left: 0;
li {
display: inline-block;
ul {
display: none;
}
&:not(:last-child) {
margin-right: .5em;
}
&:hover > ul {
display: inline-block;
}
&.active-link > a {
color: salmon;
}
&.active-folder > a {
color: orange;
}
}
}
}
Any help would be appreciated. Feel free to offer css and js solutions. Thanks!
Here is an example of what I want to impliment: codepen
Check this fiddle .
This should give you an idea about how the requirement can be achieved.
$(document).on("click","#button", function(){
$('#div2').animate({ width:"20%" }, 200);
$('#div1').animate({width:"80%" }, 200);
});
$(document).on("click","#close", function(){
$('#div2').animate({visibility:"hidden" , width:"0%" }, 200);
$('#div1').animate({width:"100%" }, 200);
});
#div1
{
height:100%;
width:100%;
float:left;
position:fixed;
}
#div2
{
height:100%;
width:0%;
float:right;
}
#button
{
margin-top:20px;
margin-right:20px;
float:right;
}
This might give you an idea of how to achieve this.
http://thecodeplayer.com/walkthrough/off-canvas-menu-animated-links
Also foundation has a offcanvas menu in their framework that you can look at and see how they created this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.