cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

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.

            
              <div class="stars_wrap">
  <div class="star_bg">
    <div class="star_inner" style="background-color: rgb(255, 255, 255);"></div>
  </div>
  <div class="star_bg">
    <div class="star_inner" style="background-color: rgb(255, 255, 255);"></div>
  </div>
  <div class="star_bg">
    <div class="star_inner" style="background-color: rgb(255, 255, 255);"></div>
  </div>
  <div class="star_bg">
    <div class="star_inner" style="background-color: rgb(255, 255, 255);"></div>
  </div>
  <div class="star_bg">
    <div class="star_inner" style="background-color: rgb(255, 255, 255);"></div>
  </div>
  <div class="star_bg">
    <div class="star_inner" style="background-color: rgb(255, 255, 255);"></div>
  </div>
</div>

<div class="wrap">
  <button class="switch">Put the mask on</button>

  <div class="girl">
    <div class="hair"></div>

    <div class="head">
      <div class="eye left"></div>
      <div class="eye right"></div>
    </div>

    <div class="body"></div>

    <div class="leg left"></div>
    <div class="leg right"></div>

    <div class="mask">
      <div class="star"></div>
    </div>

    <div class="hand left"></div>
    <div class="hand right"></div>

    <div class="fringe"></div>
  </div>
</div>
            
          
!
            
              * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  width: 100vw;
  height: 100vh;
  background: #90caf9;
  transition: all 3s;
  overflow: hidden;
}

// bg stars
.star_bg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: 55px;
  width: 55px;
  margin: auto;
  opacity: 0;
  cursor: pointer;
  color: #fff;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  transform: translate3d(0,0,0) scale(1);
  
  &.active::before {
    background: #ffe082;
  }

  .star_inner {
    display: block;
    width: 100%;
    height: 100%;
    background-color: rgb(255, 255, 255);
    .mxn_star();
  transform: translateZ(0);
  }
}

.wrap {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 170px;
  height: 240px;
  margin: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  transform: translateZ(0);
}

.switch {
  position: absolute;
  bottom: 100%;
  left: 50%;
  height: 35px;
  padding: 0 15px;
  background: #673ab7;
  outline: none;
  border: none;
  border-radius: 3px;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  cursor: pointer;
  color: #fff;
  text-transform: uppercase;
  font-weight: bold;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 16px;
  line-height: 35px;

  &:hover {
    background: darken(#673ab7, 10%);
  }
}

// girl
.girl {
  position: relative;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 5px fade(#fff, 1%));
  transform: translateZ(0);
}

/* girl */
.hair {
  position: absolute;
  top: 7px;
  right: 15px;
  width: 140px;
  height: 180px;
  border-radius: 70px 70px 10px 10px;
  margin: auto;
  background: #212121;
  transform-origin: 70px 70px;
  transform: translateZ(0);
}

.head {
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  height: 120px;
  width: 120px;
  margin: auto;
  border-radius: 50%;
  background: #ffe082;
}

.eye {
  position: absolute;
  top: 25px;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: #fff;
  overflow: hidden;

  &::before {
    content: "";
    position: absolute;
    top: 6px;
    right: 0;
    left: 0;
    width: 40px;
    height: 40px;
    margin: auto;
    border-radius: 50%;
    background: #212121;
  }

  &.left {
    left: 10px;
  }

  &.right {
    right: 10px;
  }
}

.body {
  position: absolute;
  top: 150px;
  right: 0;
  left: 0;
  width: 50px;
  height: 90px;
  margin: auto;
  background: #673ab7;
  border-radius: 10px;
}

.leg {
  position: absolute;
  top: 250px;
  width: 20px;
  height: 90px;
  background: #212121;
  border-radius: 5px;

  &.left {
    left: 60px;
  }

  &.right {
    right: 60px;
  }
}

.mask {
  position: absolute;
  top: 150px;
  left: 0;
  right: 0;
  height: 120px;
  width: 120px;
  overflow: hidden;
  margin: auto;
  border-radius: 50%;
  background: #fff;
  // webkit
  -webkit-mask-image: radial-gradient(
      circle at 33px 47px,
      transparent,
      transparent 21px,
      #fff 22px
    ),
    radial-gradient(
      circle at 27px 47px,
      transparent,
      transparent 21px,
      #fff 22px
    );
  -webkit-mask-size: 50% 100%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: 0 0, 100% 0;
  -webkit-mask-mode: luminance;
  // other
  mask-image: radial-gradient(
      circle at 33px 47px,
      transparent,
      transparent 21px,
      #fff 22px
    ),
    radial-gradient(
      circle at 27px 47px,
      transparent,
      transparent 21px,
      #fff 22px
    );
  mask-size: 50% 100%;
  mask-repeat: no-repeat;
  mask-position: 0 0, 100% 0;
  mask-mode: luminance;
  transform: translateZ(0);
}

.star {
  position: absolute;
  top: 11px;
  left: -4px;
  height: 75px;
  width: 75px;
  background: #212121;
  .mxn_star();
  transform: translateZ(0);
}

.hand {
  position: absolute;
  top: 200px;
  width: 30px;
  height: 30px;
  background: #ffe082;
  border-radius: 50%;

  &.left {
    left: 10px;
  }

  &.right {
    right: 10px;
  }
}

.fringe {
  position: absolute;
  top: 18px;
  right: 0;
  left: 0;
  width: 100px;
  height: 27px;
  margin: auto;
  background: #212121;
  border-radius: 40px 40px 20px 20px;
}

.starchild {
  background: #212121;

  .wrap {
    transform: translateY(-50px);
    cursor: default;
    transition: all 2s 3s;
  }

  .switch {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }

  .girl {
    filter: drop-shadow(0 0 20px #fff);
    transition: all 1s 2s;
    animation: ani_floating 2s 3s ease-in-out alternate infinite;
  }
  .hair {
    height: 300px;
    transition: all 1s 2s ease-in;
  }
  .mask {
    animation: ani_move 2s ease-out forwards;
  }
  .hand {
    animation: ani_move 2s ease-out alternate 2;
  }
  .star {
    animation: ani_rotate 3s linear infinite;
  }
  .eye::before {
    transform: translateY(-3px);
    transition: all 0.2s 2s;
  }
  
  .star_bg {   
    opacity: 1;
    transition: all 1s 3s ease-in;
    
    &:nth-child(1) { transform: translate3d(-150px,-150px,0) scale(1); }
    &:nth-child(2) { transform: translate3d(-200px,0,0) scale(1); }
    &:nth-child(3) { transform: translate3d(-150px,150px,0) scale(1); }
    &:nth-child(4) { transform: translate3d(150px,-150px,0) scale(1); }
    &:nth-child(5) { transform: translate3d(200px,0,0) scale(1); }
    &:nth-child(6) { transform: translate3d(150px,150px,0) scale(1); }
    
    .star_inner {
      animation: ani_rotate 2s linear infinite;
    }
    
    &:nth-child(1) .star_inner { animation-delay: .1s; }
    &:nth-child(2) .star_inner { animation-delay: .3s; }
    &:nth-child(3) .star_inner { animation-delay: .2s; }
    &:nth-child(4) .star_inner { animation-delay: .4s; }
    &:nth-child(5) .star_inner { animation-delay: .6s; }
    &:nth-child(6) .star_inner { animation-delay: .5s; }
  }
}

@keyframes ani_floating {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-20px);
  }
}

@keyframes ani_rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes ani_move {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-130px);
  }
}

.mxn_star {
  -webkit-clip-path: polygon(
    50% 0%,
    66% 28%,
    98% 35%,
    76% 59%,
    79% 91%,
    50% 76%,
    21% 91%,
    25% 60%,
    2% 35%,
    34% 28%
  );
  clip-path: polygon(
    50% 0%,
    66% 28%,
    98% 35%,
    76% 59%,
    79% 91%,
    50% 76%,
    21% 91%,
    25% 60%,
    2% 35%,
    34% 28%
  );
  transform-origin: 50% 48%;
}

            
          
!
            
              let btn = document.querySelector('.wrap');
let body = document.querySelector('body');
let stars = document.querySelectorAll('.star_inner');
let colors = ['rgb(255, 255, 255)','rgb(127, 140, 141)','rgb(149, 165, 166)','rgb(189, 195, 199)','rgb(192, 57, 43)','rgb(231, 76, 60)','rgb(211, 84, 0)','rgb(230, 126, 34)','rgb(243, 156, 18)','rgb(241, 196, 15)'];

btn.addEventListener('click',() => {
  body.classList.add('starchild');
});

for (let star of stars){
  star.addEventListener('click',function(){
    this.style.backgroundColor = randomColor(this.style.backgroundColor);
  });
}

function randomColor(pOld){
  let colorOld = pOld;
  let colorNew = colors[Math.floor(Math.random() * colors.length)];
  
  if (colorOld === colorNew) { return randomColor(colorOld); }
  else { return colorNew; }
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console