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="message">
   <button class="message__btn">click me</button>
<p class="message__text"></p> 
   </div>
<button class="reload">reload</button>

<!-- particles.js container -->
<div id="particles-js"></div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Bungee&display=swap");
$font: "Bungee", cursive;

@mixin delay {
   @for $i from 1 through 100 {
      &:nth-child(#{$i}) {
         animation-delay: #{0.4 + $i * 0.2}s;
      }
   }
}

$m-01: #cc444b;
$m-02: #ff6b6b;
$m-03: #e63946;
$m-04: #f27059;

@mixin md {
   @media screen and (max-width: 900px) {
      @content;
   }
}

* {
   margin: 0;
   padding: 0;
   list-style: none;
   border: 0;
   -webkit-tap-highlight-color: transparent;
   text-decoration: none;
   color: inherit;
   box-sizing: border-box;

   &:focus {
      outline: 0;
   }

   input::-webkit-outer-spin-button,
   input::-webkit-inner-spin-button {
      -webkit-appearance: none;
      margin: 0;
   }
}
span {
   display: block;
}
body {
   display: flex;
   justify-content: center;
   align-items: center;
   height: 100vh;
   background-color: #f79d65;
      font-family: $font;
   user-select: none;
}

.message {
   $this: &;
   width: 150px;
   height: 150px;
   border-radius: 100%;
   display: flex;
   justify-content: center;
   align-items: center;
   background-color: transparent;
   transition: all 0.4s ease;

   &.clicked {
      background-color: $m-02;
      border-radius: 0;
      width: 100%;
      height: 100vh;
      transition: all 1s ease;
         box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
      
      &:hover {
         transform: none;
         box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
      }
      #{$this} {
         &__btn {
            display: none;
         }
         &__text {
            opacity: 1;
            visibility: visible;
            animation: text 0.6s 1s ease both;

      @keyframes text {   
         0% {
           opacity:0;
            transform: translatey(80px);
         }
         100% {
            opacity:1;
            transform: translatey(0px);
         }
      }
         }
      }
   }

   &__btn {
      background-color: $m-02;
      width: 100%;
      height: 100%;
      border-radius: 50%;
      transition: all 0.2s cubic-bezier(0.55, 0.41, 0.37, 1.41);
      cursor: pointer;
      font-family: $font;
      color: white;
      letter-spacing: 2px;
      z-index:2;
      border: 2px solid $m-01;
   box-shadow: 0px 8px 0px -2px $m-03, 0px 8px 0px 0px $m-01;
      
      &:hover {
      transform: translatey(3px);
     box-shadow: 0px 0px 0px -2px $m-03, 0px 0px 0px 0px $m-01; 
   }
   }

   &__text {
      opacity: 0;
      visibility: hidden;
      position: absolute;
      display: flex;
      z-index: 1;  
   }

   &__letters {
       font-size: 80px;
      padding: 10px;
      margin: 0 -5px;
      text-transform: uppercase;
      position: relative;
      -webkit-text-stroke: 2px $m-01;
      animation: letters 1s ease infinite alternate both;
      @include delay;
      
         @include md {
      font-size: 40px;
            padding: 5px;
   }

      @keyframes letters {
         0% {
            transform: translatey(20px);
         }
         100% {
            transform: translatey(-20px);
         }
      }

      &:hover {
         animation-play-state: paused;
         #{$this} {
            &__letterMain {
               transform: translatey(-20px);
               transition: all 0.4s ease, transform 0.4s ease;
            }
            &__letterShadow {
               transform: translatey(-30px);
               filter: blur(10px);
               transition: all 0.4s ease, transform 0.4s ease;
            }
         }
      }
   }

   &__letterMain {
      position: relative;
      user-select: none;
      z-index: 1;
      transition: all 0.4s ease, transform 2s 0.4s ease;
   }

   &__letterShadow {
      position: absolute;
      left: 10px;
      top: 20px;
      color: $m-03;
      transition: all 0.4s ease, transform 2s 0.4s ease;
      
      @include md {

      top: 10px;
      }
   }
}

.reload {
   position: absolute;
   right:20px;
   top: 20px;
   z-index: 1;
   border-radius: 40px;
   background-color: $m-04;
   width: 100px; 
   height: 40px;
   font-family: $font;
   color: white;
   font-size: 10px;
   letter-spacing: 2px;
   border: 2px solid $m-01;
   box-shadow: 0px 6px 0px -2px $m-03, 0px 6px 0px 0px $m-01;
   transition: all 0.2s ease;
   cursor: pointer;
   display: none;
   
   &:focus, &:hover {
      transform: translatey(3px);
     box-shadow: 0px 0px 0px -2px $m-03, 0px 0px 0px 0px $m-01; 
   }
   

}

canvas {
  display: block;
  vertical-align: bottom;
   z-index:-1;
}

/* ---- particles.js container ---- */

#particles-js {
  position: absolute;
  width: 100%;
  height: 100%;
  //background-color: #b61924;
  background-image: url("");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: 50% 50%;
  visibility: hidden;
   transform: scale(0);
   transition: all 0.4s ease;
   
   &.show {
      visibility:visible;
      transform: scale(1);
   }

   
}
              
            
!

JS

              
                function message() {
const message = "happy birthday",
   messageText = document.querySelectorAll(".message__text"),
   messageSplit = message.split(""),
      messageContainer = document.querySelector(".message"),
      messageBtn = document.querySelector(".message__btn"),
      reloadBtn = document.querySelector(".reload"),
      particlesContainer = document.getElementById("particles-js");

const colors = ["#f7b267", "#f79d65", "#f4845f", "#f27059", "#f25c54"];
let i = 0;

messageBtn.addEventListener("click", openMessage);
reloadBtn.addEventListener("click", openMessage);

//Open Message
function openMessage() {
       if(messageContainer.classList.contains("clicked")) {
          messageContainer.classList.remove("clicked");
          reloadBtn.style.display ="none";
          particlesContainer.classList.remove("show");
       } else {
          messageContainer.classList.add("clicked");
          reloadBtn.style.display = "block";
          setTimeout(() => {
            particlesContainer.classList.add("show");
        }, 1000);
          
       }
}


// Get Message ans Split Chars
messageSplit.forEach(function (el) {
   let template = `
      <p class="message__letters">
         <span class="message__letterMain">${el}</span>
         <span class="message__letterShadow">${el}</span>
      </p>`;

   messageText.forEach(function (el) {
      el.insertAdjacentHTML("beforeend", template);
   });
});


// Add colours to Letters
const letterMain = document.querySelectorAll(".message__letterMain");
letterMain.forEach(function (el) {
   if(i == colors.length) i=0
    el.style.color = colors[i];
      i++;
});
}

message();


/// Particle JS

/* ---- particles.js config ---- */

particlesJS("particles-js", {
   particles: {
      number: { value: 80, density: { enable: true, value_area: 800 } },
      color: { value: ["#f7b267", "#f79d65", "#f4845f", "#f27059", "#f25c54", "#ffffff", "#cc444b", "#ff6b6b","#e63946" ] },
      shape: {
         type: "circle",
         stroke: { width: 0, color: "#000000" },
         polygon: { nb_sides: 5 },
         image: { src: "img/github.svg", width: 100, height: 100 }
      },
      opacity: {
         value: 1,
         random: false,
         anim: { enable: false, speed: 1, opacity_min: 0.1, sync: false }
      },
      size: {
         value: 6,
         random: true,
         anim: { enable: false, speed: 40, size_min: 0.1, sync: false }
      },
      line_linked: {
         enable: false,
         distance: 150,
         color: "#ffffff",
         opacity: 0.4,
         width: 1
      },
      move: {
         enable: true,
         speed: 6,
         direction: "top",
         random: true,
         straight: false,
         out_mode: "bounce",
         bounce: false,
         attract: { enable: false, rotateX: 600, rotateY: 1200 }
      }
   },
   interactivity: {
      detect_on: "canvas",
      events: {
         onhover: { enable: true, mode: "repulse" },
         onclick: { enable: true, mode: "push" },
         resize: true
      },
      modes: {
         grab: { distance: 400, line_linked: { opacity: 1 } },
         bubble: { distance: 400, size: 40, duration: 2, opacity: 8, speed: 3 },
         repulse: { distance: 150, duration: 0.4 },
         push: { particles_nb: 4 },
         remove: { particles_nb: 2 }
      }
   },
   retina_detect: true
});

              
            
!
999px

Console