Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                    <div class="button">
      <div class="trigger"><span></span></div>
    </div>

    <!-- made in jssecrets.com -->
    <a class="jssecrets" href="https://jssecrets.com/" target="_blank"
      >jssecrets.com</a
    >
    <!-- made in jssecrets.com -->
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Urbanist:wght@500&display=swap");
*,
::before,
::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

ul {
  list-style: none;
}

body {
  height: 100vh;
  background: radial-gradient(circle, rgb(255, 255, 255) 70%, rgb(243, 243, 243) 100%);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  color: #292d34;
}

.button {
  width: 160px;
  height: 160px;
  border-radius: 100%;
  cursor: pointer;
  position: relative;
  background: #7b42d1;
  box-shadow: 0 10px 25px rgba(123, 66, 209, 0.4);
}
.button .trigger {
  width: 96px;
  height: 60px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.button .trigger span {
  position: relative;
  width: 100%;
  height: 12px;
  transform: translateY(24px);
  background-color: white;
  display: block;
  border-radius: 9px;
  animation: opacityOn 0.5s linear both;
}
.button .trigger span::before, .button .trigger span::after {
  position: absolute;
  content: "";
  width: 100%;
  height: 12px;
  background-color: white;
  display: block;
  border-radius: 9px;
}
.button .trigger span::before {
  transform: translateY(-24px);
  animation: downAndTurnReverse 0.5s linear both;
}
.button .trigger span::after {
  transform: translateY(24px);
  animation: upAndTurnReverse 0.5s linear both;
}
.button .trigger.active span {
  animation: opacityOff 0.5s linear both;
}
.button .trigger.active span::before {
  animation: downAndTurn 0.5s linear both;
}
.button .trigger.active span::after {
  animation: upAndTurn 0.5s linear both;
}

@keyframes downAndTurn {
  0% {
    transform: translateY(-24px) rotate(0deg);
  }
  50% {
    transform: translateY(0px) rotate(0deg);
  }
  100% {
    transform: translateY(0px) rotate(45deg);
  }
}
@keyframes downAndTurnReverse {
  0% {
    transform: translateY(0) rotate(45deg);
  }
  50% {
    transform: translateY(0px) rotate(0deg);
  }
  100% {
    transform: translateY(-24px) rotate(0deg);
  }
}
@keyframes upAndTurn {
  0% {
    transform: translateY(24px) rotate(0deg);
  }
  50% {
    transform: translateY(0px) rotate(0deg);
  }
  100% {
    transform: translateY(0px) rotate(-45deg);
  }
}
@keyframes upAndTurnReverse {
  0% {
    transform: translateY(0px) rotate(-45deg);
  }
  50% {
    transform: translateY(0px) rotate(0deg);
  }
  100% {
    transform: translateY(24px) rotate(0deg);
  }
}
@keyframes opacityOff {
  0% {
    background-color: white;
  }
  49% {
    background-color: white;
  }
  50% {
    background-color: rgba(255, 255, 255, 0);
  }
  100% {
    background-color: rgba(255, 255, 255, 0);
  }
}
@keyframes opacityOn {
  0% {
    background-color: rgba(255, 255, 255, 0);
  }
  49% {
    background-color: rgba(255, 255, 255, 0);
  }
  50% {
    background-color: white;
  }
  100% {
    background-color: white;
  }
}
.jssecrets {
  font-weight: 500;
  text-decoration: none !important;
  font-family: "Urbanist";
  padding: 16px;
  background: #ffc805;
  color: #000000;
  font-size: 1.2em;
  letter-spacing: 0.2px;
  border-radius: 8px;
  box-shadow: 0px 4px 12px rgba(184, 144, 0, 0.1882352941), 0px 8px 24px rgba(184, 144, 0, 0.3764705882);
  position: absolute;
  bottom: 24px;
  right: 24px;
  transition: all 0.3s;
}
.jssecrets:hover {
  transform: translateY(-4px);
}
              
            
!

JS

              
                // Variables

const trigger = document.querySelector('.trigger');

// Functions

const iconToggle = (event) => {
  event.currentTarget.classList.toggle('active');
};

// Event Listeners

trigger.addEventListener('click', iconToggle);

              
            
!
999px

Console