Coder Wrap provides free to use snippets Coder Wrap provides free to use snippets

Back to Others
Preview Source Code
Download
HTML
CSS
/**Typeo CSS Start (Note if is not need so remove)**/
@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");
* {
  box-sizing: border-box;
}

body {
  font-family: "Poppins", sans-serif;
  color: #000;
  box-sizing: border-box;
  background: #2c2c2c;
}
.cw-fix {
  max-width: 700px;
  margin: auto;
  width: 100%;
  text-align: center;
  padding-top: 5%;
}
/**Typeo CSS End (Note if is not need so remove)**/
/* nav-icon-1 */
.cw-nav-icon-1 {
  width: 30px;
  height: 30px;
  position: relative;
  transition: 0.1s;
  margin: 10px 10px;
  cursor: pointer;
  display: inline-block;
}
.cw-nav-icon-1 span {
  width: 5px;
  height: 5px;
  background-color: #fff;
  display: block;
  border-radius: 50%;
  position: absolute;
}
.cw-nav-icon-1:hover span {
  transform: scale(1.2);
  transition: 350ms cubic-bezier(0.8, 0.5, 0.2, 1.4);
}
.cw-nav-icon-1 span:nth-child(1) {
  left: 0;
  top: 0;
}
.cw-nav-icon-1 span:nth-child(2) {
  left: 12px;
  top: 0;
}
.cw-nav-icon-1 span:nth-child(3) {
  right: 0;
  top: 0;
}
.cw-nav-icon-1 span:nth-child(4) {
  left: 0;
  top: 12px;
}
.cw-nav-icon-1 span:nth-child(5) {
  position: absolute;
  left: 12px;
  top: 12px;
}
.cw-nav-icon-1 span:nth-child(6) {
  right: 0px;
  top: 12px;
}
.cw-nav-icon-1 span:nth-child(7) {
  left: 0px;
  bottom: 0px;
}
.cw-nav-icon-1 span:nth-child(8) {
  position: absolute;
  left: 12px;
  bottom: 0px;
}
.cw-nav-icon-1 span:nth-child(9) {
  right: 0px;
  bottom: 0px;
}
.cw-nav-icon-1.open {
  transform: rotate(180deg);
  cursor: pointer;
  transition: 0.2s cubic-bezier(0.8, 0.5, 0.2, 1.4);
}
.cw-nav-icon-1.open span {
  border-radius: 50%;
  transition-delay: 200ms;
  transition: 0.5s cubic-bezier(0.8, 0.5, 0.2, 1.4);
}
.cw-nav-icon-1.open span:nth-child(2) {
  left: 6px;
  top: 6px;
}
.cw-nav-icon-1.open span:nth-child(4) {
  left: 6px;
  top: 18px;
}
.cw-nav-icon-1.open span:nth-child(6) {
  right: 6px;
  top: 6px;
}
.cw-nav-icon-1.open span:nth-child(8) {
  left: 18px;
  bottom: 6px;
}

/* nav-icon-2 */
.cw-nav-icon-2 {
  width: 35px;
  height: 30px;
  margin: 10px 10px;
  position: relative;
  cursor: pointer;
  display: inline-block;
}
.cw-nav-icon-2 span {
  background-color: #fff;
  position: absolute;
  border-radius: 2px;
  transition: 0.3s cubic-bezier(0.8, 0.5, 0.2, 1.4);
  width: 100%;
  height: 4px;
  transition-duration: 500ms;
}
.cw-nav-icon-2 span:nth-child(1) {
  top: 0px;
  left: 0px;
}
.cw-nav-icon-2 span:nth-child(2) {
  top: 13px;
  left: 0px;
  opacity: 1;
}
.cw-nav-icon-2 span:nth-child(3) {
  bottom: 0px;
  left: 0px;
}
.cw-nav-icon-2:not(.open):hover span:nth-child(1) {
  transform: rotate(-3deg) scaleY(1.1);
}
.cw-nav-icon-2:not(.open):hover span:nth-child(2) {
  transform: rotate(3deg) scaleY(1.1);
}
.cw-nav-icon-2:not(.open):hover span:nth-child(3) {
  transform: rotate(-4deg) scaleY(1.1);
}
.cw-nav-icon-2.open span:nth-child(1) {
  transform: rotate(45deg);
  top: 13px;
}
.cw-nav-icon-2.open span:nth-child(2) {
  opacity: 0;
}
.cw-nav-icon-2.open span:nth-child(3) {
  transform: rotate(-45deg);
  top: 13px;
}
JS
const icons = document.querySelectorAll('.cw_icon');
    icons.forEach (cw_icon => {  
        cw_icon.addEventListener('click', (event) => {
            cw_icon.classList.toggle("open");
        });
    });

Related Snippets

Leave a comment

Your email address will not be published. Required fields are marked *