Animated Social Sharing Popup Menu

Category: Javascript , Menu & Navigation , Social Media | August 18, 2022
Author:BatinErenKeskin
Views Total:47 views
Official Page:Go to website
Last Update:August 18, 2022
License:MIT

Preview:

Animated Social Sharing Popup Menu

Description:

An animated popup menu for social sharing. Written in CSS and a little bit of JavaScript.

How to use it:

1. Add the popup menu together with a toggle button to the page.

<div class="navigation">
  <!-- Menu Toggler -->
  <div class="menuToggle"></div>
  <!-- Menu Items -->
  <div class="menu">
    <ul>
      <li style="--i:0.1s;"><a href="#">Social Icon 1</a></li>
      <li style="--i:0.2s;"><a href="#">Social Icon 2</a></li>
      <li style="--i:0.3s;"><a href="#">Social Icon 3</a></li>
    </ul>
  </div>
</div>

2. Add the following CSS snippets to the page.

.navigation {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}
.menuToggle {
  position: relative;
  width: 70px;
  height: 70px;
  background: #fff;
  border-radius: 70px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 15px 25px rgba(0, 0, 0, 0.15);
}
.menuToggle::before {
  content: '+';
  position: absolute;
  font-size: 3em;
  font-weight: 200;
  color: #ff216d;
  transition: 1.5s;
}
.menuToggle.active::before {
  transform: rotate(225deg);
}
.menu {
  position: absolute;
  width: 30px;
  height: 30px;
  background: #fff;
  border-radius: 70px;
  z-index: -1;
  transition: transform 0.5s, width 0.5s, height 0.5s;
  transition-delay: 1s, 0.5s, 0.5s;
  transition-timing-function: cubic-bezier(0.075, 0.82, 0.165, 1);
}
.menuToggle.active~.menu {
  width: 240px;
  height: 70px;
  z-index: 1;
  transform: translateY(-100px);
  transition-delay: 0s, 0.5s, 0.5s;
  box-shadow: 0 15px 25px rgba(0, 0, 0, 0.1);
}
.menu::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  left: calc(50% - 8px);
  bottom: 4px;
  transform: rotate(45deg);
  border-radius: 2px;
  transition: 0.5s;
}
.menuToggle.active~.menu::before {
  transition-delay: 0.5s;
  bottom: -6px;
}
.menu ul {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: start;
  height: 70px;
  gap: 40px;
  padding: 0;
}
.menu ul li {
  list-style: none;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-30px);
  transition: 0.25s;
  transition-delay: calc(0s + var(--i));
}
.menuToggle.active~.menu ul li {
  opacity: 1;
  visibility: visible;
  transform: translateY(0px);
  transition-delay: calc(0.75s + var(--i));
}
.menu ul li a {
  display: block;
  font-size: 2em;
  text-decoration: none;
  color: #555;
}
.menu ul li a:hover {
  color: #ff216d !important;
  cursor: pointer;
}

3. The required JavaScript to enable the toggle button to open the popup menu.

let menuToggle = document.querySelector('.menuToggle');
menuToggle.onclick=function(){
  menuToggle.classList.toggle('active')
}

You Might Be Interested In:


Leave a Reply