In this tutorial we’ll show you how to build a slide-out navigation menu. jQuery slide out menu is a common trend in modern web design, and you can see that many websites prefer that type of menu. It removes clutter from the page, and makes it more readable, allowing you to put all the emphasis on the content.
It's a great way to achieve minimalist layout for your site that would be free from distractions. Today I’ll show you how to build such a menu on your own by using:
In order to build the navigation menu, let's take a look at the document set-up first:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Animation Menu Demo</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css">
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js"></script>
<script src="script.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- Content goes here -->
</body>
</html>
First off, we’re loading Normalize.css in order to change the default browser styles, and make sure that our menu looks the same in every browser. We’re using FontAwesome to display an arrow in front of the menu item with sub-items. We also load jQuery to toggle the classes in the menu, and move all the custom jQuery code to script.js. The last link is the main stylesheet for our project.
A hamburger button is a common attribute of a website’s navigation. Quite often it is made with an icon font, such as FontAwesome, but in this tutorial I’d like to add some animation to it, so we’ll be building it from a scratch. Basically, our button is a span, containing three divs displayed as horizontal bars.
<span class="toggle-button">
<div class="menu-bar menu-bar-top"></div>
<div class="menu-bar menu-bar-middle"></div>
<div class="menu-bar menu-bar-bottom"></div>
</span>
The styles look as follows:
.toggle-button {
position: fixed;
width: 44px;
height: 40px;
padding: 4px;
transition: .25s;
z-index: 15;
}
.toggle-button:hover {
cursor: pointer;
}
.toggle-button .menu-bar {
position: absolute;
border-radius: 2px;
width: 80%;
transition: .5s;
}
.toggle-button .menu-bar-top {
border: 4px solid #555;
border-bottom: none;
top: 0;
}
.toggle-button .menu-bar-middle {
height: 4px;
background-color: #555;
margin-top: 7px;
margin-bottom: 7px;
top: 4px;
}
.toggle-button .menu-bar-bottom {
border: 4px solid #555;
border-top: none;
top: 22px;
}
.button-open .menu-bar-top {
transform: rotate(45deg) translate(8px, 8px);
transition: .5s;
}
.button-open .menu-bar-middle {
transform: translate(230px);
transition: .1s ease-in;
opacity: 0;
}
.button-open .menu-bar-bottom {
transform: rotate(-45deg) translate(8px, -7px);
transition: .5s;
}
The button has a fixed position, and doesn’t move when you scroll the page. It also has a z-index of 15, so that it always remains on top of other elements and overlaps them. The button consists of three bars. Each bar shares some styles with each other, so I moved them into the .menu-bar
class. The rest of the styles are moved into separate classes. The “magic” happens when we add another class to the containing span, which is .button-open
. We add it with the help of jQuery like this:
$(document).ready(function() {
var $toggleButton = $('.toggle-button');
$toggleButton.on('click', function() {
$(this).toggleClass('button-open');
});
});
For those of you unfamiliar with jQuery, let me explain what is going on here. First, we initialize a variable called $toggleButton
, which contains our button. We store it in a variable, so that JavaScript doesn’t need to search through our document and look for the button each time we click on it. Then we create an event listener that listens to the clicks being made on the button. Each time the button is clicked, the event listener fires the function toggleClass() that toggles the .button-open
class.
When the .button-open
class is added we can use it to change the way of how the elements are displayed. We’re using the CSS3 translate() and rotate() functions to make the top and bottom bars rotate to 45 degrees, and the middle bar drift to the right and disappear. You can play around with the button and change its properties in the Codepen demo:
Now that we have our button created, let’s actually make it useful and create the menu that slides in and out when we click the button. Here’s how the markup of the menu looks like:
<div class="menu-wrap">
<div class="menu-sidebar">
<ul class="menu">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Blog</a></li>
<li class="menu-item-has-children"><a href="#">Click The Arrow</a>
<span class="sidebar-menu-arrow"></span>
<ul class="sub-menu">
<li><a href="#">Alignment</a></li>
<li><a href="#">Markup</a></li>
<li><a href="#">Comments</a></li>
</ul>
</li>
<li><a href="#">Courses</a></li>
<li><a href="#">Get In Touch</a></li>
</ul>
</div>
</div>
I won’t go in detail about each style for this menu, instead I’ll just focus on a few important points here. First of all it’s the div with .menu-wrap
class. Look at its styles:
.menu-wrap {
background-color: #6968AB;
position: fixed;
top: 0;
height: 100%;
width: 280px;
margin-left: -280px;
font-size: 1em;
font-weight: 700;
overflow: auto;
transition: .25s;
z-index: 10;
}
The position is fixed, so the menu stays always at the same place when the page is scrolled. The height 100% allows the menu to take up all the vertical space on the page. Notice that the margin-left is set to a negative number, which equals to the menu width. This makes the menu disappear from the viewport. In order to make it visible again, we create another class toggler with jQuery. Our JavaScript file would look like this:
$(document).ready(function() {
var $toggleButton = $('.toggle-button'),
$menuWrap = $('.menu-wrap');
$toggleButton.on('click', function() {
$(this).toggleClass('button-open');
$menuWrap.toggleClass('menu-show');
});
});
We add another variable $menuWrap
which contains the menu wrapper, and use the same event handler for the button we created earlier. Only this time we toggle two classes, one for the button, and one for the menu wrapper. The .menu-show
class sets the left margin to 0, and adds some box shadow effect.
.menu-show {
margin-left: 0;
box-shadow: 4px 2px 15px 1px #B9ADAD;
}
You might notice that one of the list items has the class .menu-item-has-children
and contains a sub-menu. Also, right after the link, there’s a span with the class .sidebar-menu-arrow
.
<li class="menu-item-has-children"><a href="#">Click The Arrow</a>
<span class="sidebar-menu-arrow"></span>
<ul class="sub-menu">
<!-- List items -->
</ul>
</li>
The span has an ::after
pseudo-element that contains a FontAwesome arrow. By default the sub-menu is hidden, and would be visible only if you click the arrow. Here’s how we do it with jQuery:
$(document).ready(function() {
var $sidebarArrow = $('.sidebar-menu-arrow');
$sidebarArrow.click(function() {
$(this).next().slideToggle(300);
});
});
When we click the arrow, a function is called, which targets the next element right after the span (in our case it’s the sub-menu), and makes it visible. The function we’re using is slideToggle. It makes an element appear and disappear using a sliding motion. The function in our example has one parameter, which is the animation duration.
Lastly, the menu items in our demo have a hover effect. It is created using an ::after
pseudo-element. The code looks as follows:
.menu-sidebar li > a::after {
content: "";
display: block;
height: 0.15em;
position: absolute;
top: 100%;
width: 102%;
left: 50%;
transform: translate(-50%);
background-image: linear-gradient(to right, transparent 50.3%, #FFFA3B 50.3%);
transition: background-position .2s .1s ease-out;
background-size: 200% auto;
}
.menu-sidebar li > a:hover::after {
background-position: -100% 0;
}
The ::after
pseudo-element contains an absolutely positioned block level element at the bottom of each link, with the height of 0.15em and a full width. In other words it’s our underline. What is special here is that we don’t just apply the background color to the line, we’re using the linear-gradient() function on the background image. Although this function is intended for making color gradients, we can make an abrupt color change by specifying the percentages.
.menu-sidebar li > a::after {
background-image: linear-gradient(to right, transparent 50.3%, #FFFA3B 50.3%);
}
Here a half of the line is transparent, and another half is yellow. By making the background size 200% we double the width of our block, so that the transparent part takes up all the width of the link, and the other, yellow part, is moved to the left and we don’t see it. On hover we change the background position to -100%, which moves our double-sized line. The yellow part becomes visible, and the transparent part is now hidden.
Instead of the transparent part you can use any other color. This would create an illusion of the line filled up by another color, but in reality it’s just a two-colored line. You can also experiment with gradients, instead of making an abrupt color change like we did here.
Go ahead and take a look at what we’ve built. Each of the elements we examined separately act together as a whole. Also, feel free to download the source code for this tutorial and use it for your own projects.
For those who skipped the entire CSS & jQuery part because coding is way more complicated than you thought it would be, I have some great news. WordPress took care of non-professional users by creating multiple plugins for a more convenient drag-and-drop customization.
What you’ll need is a JetMenu plugin to create a convenient slide-out menu using Elementor live content builder. This means you can easily add Elementor models to menu items by just moving them with your mouse cursor.
For regular users, this plugin is everything. Not only is its drag-and-drop customization easy and fast, but also diverse in menu designs. And don’t worry about the responsiveness of your slide-out menu - it will look awesome on all types of screens.
Take a look at this video and you’ll understand why JetMenu plugin is so easy to work with (not to say it’s not as confusing as messing with CSS & jQuery code):
Finally, JetMenu is fully compatible with Avada, BeTheme, and Enfold WordPress themes, and other WordPress Elementor themes. It comes with a set of documentation and 24/7 support for you to contact the developers in case of any issue or questions.
If you have any questions let me know in the comments below.
If you already have a working web resource or blog, sometimes its functionality needs to be updated with new features. In such a situation, it is rational to re-create an html website. But, it is much faster and more efficient to implement a ready-made block of program code - a script. Here when a JavaScript comes in.
Take advantage of a fully responsive Navbar JavaScript to enhance your website navigation. The vendor provides 8 beautiful layouts for you to select the most suitable option for your web resource. You will discover a number of megamenus and drop-down elements to choose from. The highly customizable interface will allow you to create a unique design.
More features:
It is a navigation element that has an animation effect. It looks like a menu that smoothly slides out when the user hovers over it with a pointer.
If the menu is hidden and shows off only when the user needs it – it makes the whole website space clearer. Massy websites reduce the user experience, so it is better to keep everything in an understandable order.
Animation effects make the website look more dynamic and modern users love it. The animated menu will make your pages more visually appealing.
Subscribe to our newsletter and access exclusive content and offers available only to MonsterPost subscribers.
[url=http://seroquel.store/]seroquel sleepiness[/url]
[url=http://prozac.cfd/]prozac price[/url]
[url=http://modafinil.boutique/]provigil generic price[/url]
[url=https://buyantibiotics.shop/]tetracycline 250mg capsules online[/url]
[url=https://finasteride.best/]finasteride where can i buy[/url]
[url=https://pharmacyonline.cfd/]online pharmacy for sale[/url]
[url=http://lasix.sale/]medicine furosemide 40 mg[/url]
[url=https://azithromycin.digital/]zithromax capsules 250mg[/url]
[url=http://buycialis20pill.monster/]cialis prescription online canada[/url]
[url=https://orderviagrapillnoprescription.monster/]cheap viagra from canada[/url]
[url=https://genericviagra50mgpill.monster/]canada prescription viagra[/url]
[url=http://buyviagra50bestprice.monster/]viagra online cheap price[/url]
[url=http://genericcialis20mgtab.quest/]cheap real cialis[/url]
[url=http://viagraonlinemedicationpharmacy.quest/]generic viagra coupon[/url]
[url=http://viagradrugwithoutprescription.quest/]cheap viagra for sale canada[/url]
[url=https://buyingcialistabletsonline.monster/]cialis brand name in india[/url]
[url=https://genericcialispillforsaleonline.quest/]cialis australia cost[/url]
[url=http://buybestcialispillsonline.monster/]cialis otc[/url]
[url=https://bestviagratabsorder.quest/]cost of sildenafil 100mg tablets[/url]
[url=http://viagraonlinesale.monster/]female viagra singapore[/url]
[url=https://buyviagrawithoutprescription.monster/]viagra australia pharmacy[/url]
It is really a great and useful piece of information. I’m glad that you simply shared this useful info with us. Please keep us up to date like this. Thanks for sharing
[url=https://budesonidebudecort.monster/]budesonide prices pharmacy[/url]
hydroxychloroquine 200mg doctors prescribing hydroxychloroquine near me
[url=https://onlinedrugstore.store/]canadian pharmacy viagra 100mg[/url]
[url=http://vermoxforsale.com/]vermox 500mg tablet price[/url]
[url=https://vermox.sale/]vermox from mexico[/url]
[url=https://prozac.store/]prozac pill[/url]
[url=http://medroltabs.com/]cheap medrol[/url]
[url=http://motrinibuprofen.monster/]prescription motrin 800[/url]
[url=http://cheapdrugs.store/#]erectile dysfunction treatment[/url]
[url=http://viagrabuyonline.quest/]best price for sildenafil 20 mg[/url]
[url=http://accutane.store/]accutane 60 mg daily[/url]
[url=https://sildalissildenafiltadalafil.monster/]sildalis tablets[/url]
[url=http://pentoxifyllinetrental.monster/]trental cost india[/url]
[url=https://buyingviagrapills.quest/]buying generic viagra[/url]
Vegas Crest Casino Go Bananas The site has a great Withdrawals process within 24 hours and the withdrawal limits at Lucky Days Casino are 4,000 EUR day, 16,000 EUR week, 50,000 EUR month. We already have countless players just like you who are winning real money playing all of their favourite casino games online right now. Being an online destination, we have the flexibility to offer hundreds of games, including some innovative new card games alongside tried and tested favourites like a Night With Cleo. We run a range of tournaments, promotional offers and regular bonuses to keep all of our players happy and excited to play. When you join CafГ© Casino online, you have the chance to participate in some of the most thrilling and highest paying casino classics available to play online. A. Bitcoin Casinos are a type of online casino that accept cryptocurrencies, such as BTC. http://mariofynd108753.blogvivi.com/13382387/free-online-casino-games-to-download partypoker Poker app is naturally available for any type of smartphone, whether you have an iPhone, Android phone, Blackberry or a Windows phone. We tested the app with an iPhone 8 with the latest update of iOS on it, and everything ran very smoothly. If you want to become a true poker beast like our own Beasts of Poker Pro Player Joni Jouhkimainen, also a partypoker Team Pro, your choice should be partypoker! I play on Poker Stars Lite Since it’s not Completely RNG with casuals bots & morons like WSOP You actually play with users around the world Отримайте РїРѕРІРЅРёР№ доступ РґРѕ турнірних квитків С– Р±РѕРЅСѓСЃС–РІ Р·С– СЃРІРѕРіРѕ облікового запису. РљСЂС–Рј того, РІ мобільному додатку також доступна захищена Р·Р° РІСЃС–РјР° стандартами безпеки функція «Касир» РІС–Рґ 888poker. Отже, РІРё матимете можливість робити поповнення та виводити гроші Р·Р° РґРѕРїРѕРјРѕРіРѕСЋ СЃРїРѕСЃРѕР±С–РІ оплати, СЏРєРёРј РІРё надаєте перевагу.
[url=http://augmentin.shop/]augmentin 825 125 mg[/url]
[url=https://orlistatxenical.quest/]orlistat 120mg mexico[/url]
[url=http://cialisatabs.monster/]tadalafil generic over the counter[/url]
[url=https://viagraltab.quest/]viagra 100mg tablet buy online[/url]
[url=http://antabuse.life/]antabuse pills for sale[/url]
[url=http://ibuprofenmotrin.quest/]800 mg motrin[/url]
özel uçak kiralama
[url=http://mebendazolevermox.digital/]vermox pharmacy[/url]
özel jet kiralama
[url=http://baclofen.shop/]price of baclofen[/url]
[url=http://xprednisolone.com/]prednisolone 5mg without prescription[/url]
[url=http://vardenafil.shop/]levitra price australia[/url]
https://piercingxeightteen.blogspot.com
[url=http://propecia.fun/]propecia for sale canada[/url]
[url=https://viagrantabs.quest/]viagra pills online south africa[/url]
[url=http://ivermectinya.monster/]how much is ivermectin[/url]
[url=http://piroxicamfeldene.quest/]feldene capsule 20mg[/url]
[url=https://abilifyaripiprazole.quest/]buy cheap abilify[/url]
[url=http://feldene.online/]piroxicam 2mg[/url]
[url=https://lasix.world/]generic lasix 40 mg[/url]
[url=https://ordercialis20mgpill.quest/]purchase cheap cialis soft tabs[/url]
[url=https://buycialispillsonline.quest/]generic cialis paypal[/url]
[url=https://genericviagrapillswithoutrx.quest/]generic viagra price[/url]
[url=http://bestviagra150tablet.monster/]best online viagra pharmacy[/url]
[url=https://cialistabletsnorx.monster/]online pharmacy cialis india[/url]
[url=http://viagracheappillsforsale.quest/]cost of viagra[/url]
[url=https://lasix.golf/]lasix 20 mg[/url]
[url=https://gabapentinneurontin.monster/]gabapentin cap 400mg[/url]
[url=https://ivermectinsq.quest/]how much does ivermectin cost[/url]
how long does botox in bladder last
[url=https://bestcialismedicinerx.monster/]buy tadalafil online[/url]
[url=http://cialismedicinepharmacy.quest/]cheap cialis prescription[/url]
[url=http://orderviagra50mg.monster/]generic sildenafil 50mg[/url]
[url=https://ivermectinic.quest/]ivermectin price[/url]
[url=http://vardenafil.cyou/]buy generic vardenafil[/url]
[url=https://cialisbestshop.monster/]compare prices cialis[/url]
[url=https://ivermectinqx.monster/]ivermectin 4000[/url]
botox for overactive bladder uk
[url=https://buyviagra50withnoprescription.monster/]viagra for sale cheap[/url]
[url=http://buycialis40tabs.monster/]buy cialis 40 mg online[/url]
[url=https://genericviagra50mgnoprescription.quest/]cheap viagra soft tabs[/url]
Chevrolet Yedek parça
Ofis ve parça eşya taşıma işlemlerinde güvenli taşımacılık ile tanışın. Siz de evden eve ve şehirler arası nakliyat işlemlerinizde güvenilir bir firmadan hizmet alın.
Türkiye’nin en başarılı şehir içi nakliyat fiması ile evden eve taşımacılık artık çok kolay. Parça eşya taşıma, ofis taşıma ve şehirler arası nakliyat işlemleriniz için kaliteden ödün vermeyin.
viagra 50mg online pharmacy viagra
Fulya elektrikçi
[url=http://cialismedicinedrugstore.monster/]how to buy cialis online in canada[/url]
instagram takipçi hilesi
seo analiz google sıralama yarışması
pangola jewelry
asian jewelry store rochester ny
[url=http://genericcialistabrx.quest/]tadalis sx soft[/url]
casino
first phorm protein
ucuz zeytinyağı
Soğuk sıkım zeytinyağı
[url=https://bestviagra150mgwithnoprescription.quest/]prescription viagra online canada[/url]
fantastic publish, very informative. I ponder why the opposite specialists of this sector don’t understand this. You should continue your writing. I am sure, you’ve a huge readers’ base already!
SEO Analiz Google Sıralama Yarışması
first phorm
Beylikdüzü Elektrikçi
bodrum boyacı ustası
Esenyurt elektrikçi
almond eye horse next race
kadıköy eşya depolama
kadıköy eşya depolama
almond eye test
Eyüp elektrikçi
Su deposu temizliği
buy instagram mentions
coupon for cialis petcialisrov.com cialis cost per pill
botox botox near me botox before and after
botox botox near me botox before and after
botox botox near me botox before and after
dolpx
what is tadalafil used for generic tadalafil 20mg where to buy cialis canada
eyes botox
what is botox
botox gallery
vimeo video download
mitron video download
botox
term paper directions terrorism term paper topics
writing phd thesis proposal thesis pdf download free
https://play.google.com/store/apps/details?id=com.sanalexpress.walpapers
https://infomaw.com
explain unicorns essay volcanoes essay conclusion
https://gymsozluk.com
pharmacy rx one legitimate online pharmacy products
cialis online cheap cialis
cheap zithromax purchase zithromax
download iphone instagram videos online
mac free insta reels download
mac quality ig photo download
ios free instagram story download
Instagram profile picture download
instagram full hd photo download
https://whovv.com
save reels instagram
macbook ig video download
https://whovv.com
https://whovv.com
https://whovv.com
instagram free image download
can you drink after botox
can you drink after botox
cialis trial coupon generic cialis paypal payment
can you drink after botox
can you drink after botox
https://gymsozluk.com
https://gymsozluk.com
zithromax without prescription zithromax.com
https://gymsozluk.com
https://gymsozluk.com
hydroxychloroquine dosage hydroxychloroquine sulfate
https://www.gogegi.com/how-to-gain-weight-for-females-in-10-days
plaquenil generic name antimalarial drugs hydroxychloroquine
https://www.gogegi.com/lou-sulola-samuel
https://www.gogegi.com/starbucks-partner-hours
Health Supplement
S2000 Spoon Hardtop
https://chloroquinervn.com/
https://infomaw.com/
https://infomaw.com/
https://infomaw.com/
https://infomaw.com/
Schitts Creek Season 7
pay someone to write paper help writing term paper
How To Delete A Page In Word
What Do You Call A Fake Noodle
What Do You Call A Fake Noodle
How To Make Money Online
chris bumstead
chris bumstead
chris bumstead
chris bumstead
chris bumstead
Dogecoin Price Today
Ada Coin Price Prediction 2022
How To Make Nft
Dogecoin Price Prediction 2025
Yogos
Vons Chicken
canadian pharmacy viagra & cialis cialis in egypt
instagram profile picture downloader
instagram iphone online post download
instagram highlights without program download
best online pharmacy for oxycodone ramesh rx pharmacy
sildenafil natural max dose of sildenafil
generic tadalafil cost tadalafil medicine
viagra generic online viagra buy online
https://maps.google.sm/url?q=https://www.gogegi.com
http://images.google.bj/url?q=https://www.gogegi.com
https://images.google.gm/url?q=https://www.gogegi.com
Buy Instagram Likes
Starbucks Partner Hours
Ada Coin Price Prediction
cialis dosage [url=https://cialiswithdapoxetine.com/#]cialis tadalafil & dapoxetine[/url]
ivermectin overdose in dogs ivermectin sheep drench dosage
deworming chickens with ivermectin ivermectin for dogs heartworm
twitagra
twitagra
twitagra
https://gymsozluk.com
https://gymsozluk.com
https://gymsozluk.com
https://gymsozluk.com
how to download instagram quality reels
ios ig igtv download
https://www.iginsta.com
https://infomaw.com
https://infomaw.com
https://infomaw.com
https://infomaw.com
https://www.gogegi.com
https://www.gogegi.com
https://www.gogegi.com
macbook insta igtv download
nicolas iong
rxpharmacycoupons is canada drugs legit
how to get viagra without a doctor viagra commercial 2016
descarga de imagen de computadora de instagram
android ücretsiz instagram resim indirme
medplus pharmacy store locator cheap scripts pharmacy
ipad ig igtv download
jon skywalker
Instagram privát fiók fotóletöltő oldala
generic cialis fastest delivery of cialis
Instagram iPhone Online-Story-Download
cheap cialis cialis generic
Google
The time to read or pay a visit to the content material or websites we’ve linked to beneath.
100 free chinese dating sites
Google
Wonderful story, reckoned we could combine several unrelated information, nevertheless seriously worth taking a look, whoa did one particular discover about Mid East has got a lot more problerms at the same time.
Google
The time to study or stop by the content material or internet sites we’ve linked to below.
mksorb.com
[…]Here are a number of the web-sites we advise for our visitors[…]
Google
Please visit the sites we comply with, which includes this one particular, because it represents our picks in the web.
Backlink
[…]here are some links to sites that we link to simply because we think they are worth visiting[…]
Google
That could be the end of this write-up. Here youll come across some sites that we assume youll value, just click the hyperlinks.
mksorb.com
[…]we prefer to honor quite a few other net internet sites around the internet, even if they arent linked to us, by linking to them. Underneath are some webpages really worth checking out[…]
OnHax Me
[…]we like to honor many other web web pages on the internet, even if they arent linked to us, by linking to them. Below are some webpages really worth checking out[…]
Your article is helpful. Nice work keep it up ?
The link to the demo is broken.
It leads to a Slide-Out Navigation Menu.
Hey!
Thank you so much for this. I was wondering if it would be possible to get this whole thing aligned to the right instead of the left. I’ve tried tweaking some of the options myself but its just so overwhelming that I dont think I can manage.
Appreciate any help you can give!