Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

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="wrapper">
  <div id="menu" onmouseover="smallerKomadas();" onmouseout="largerKomadas();" onclick="changeKodamas();">Click Here To
    Randomize</div>
  <div class="kodamaDiv" onclick="kodamaFunc(event);">
    <div class="faceDiv">
      <div class="eyeDiv"></div>
      <div class="eyeDiv"></div>
      <div class="mouthDiv"></div>
    </div>
  </div>
  <div class="kodamaDiv" onclick="kodamaFunc(event);">
    <div class="faceDiv">
      <div class="eyeDiv"></div>
      <div class="eyeDiv"></div>
      <div class="mouthDiv"></div>
    </div>
  </div>
  <div class="kodamaDiv" onclick="kodamaFunc(event);">
    <div class="faceDiv">
      <div class="eyeDiv"></div>
      <div class="eyeDiv"></div>
      <div class="mouthDiv"></div>
    </div>
  </div>
  <div class="kodamaDiv" onclick="kodamaFunc(event);">
    <div class="faceDiv">
      <div class="eyeDiv"></div>
      <div class="eyeDiv"></div>
      <div class="mouthDiv"></div>
    </div>
  </div>
  <div class="kodamaDiv" onclick="kodamaFunc(event);">
    <div class="faceDiv">
      <div class="eyeDiv"></div>
      <div class="eyeDiv"></div>
      <div class="mouthDiv"></div>
    </div>
  </div>
  <div class="kodamaDiv" onclick="kodamaFunc(event);">
    <div class="faceDiv">
      <div class="eyeDiv"></div>
      <div class="eyeDiv"></div>
      <div class="mouthDiv"></div>
    </div>
  </div>
  <div class="kodamaDiv" onclick="kodamaFunc(event);">
    <div class="faceDiv">
      <div class="eyeDiv"></div>
      <div class="eyeDiv"></div>
      <div class="mouthDiv"></div>
    </div>
  </div>
  <div class="kodamaDiv" onclick="kodamaFunc(event);">
    <div class="faceDiv">
      <div class="eyeDiv"></div>
      <div class="eyeDiv"></div>
      <div class="mouthDiv"></div>
    </div>
  </div>
  <div class="kodamaDiv" onclick="kodamaFunc(event);">
    <div class="faceDiv">
      <div class="eyeDiv"></div>
      <div class="eyeDiv"></div>
      <div class="mouthDiv"></div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  background-color: black;
}
.wrapper {
  position: absolute;
  width: 60vh;
  height: 60vh;
  top: 50%;
  left: 50%;
  margin-top: -30vh;
  margin-left: -30vh;
}
.kodamaDiv {
  width: 15vh;
  height: 15vh;
  margin: 2.5vh;
  border-radius: 50%;
  background-color: #000000;
  float: left;
  transform: rotate(45deg);
  opacity: 0.8;
  cursor: pointer;
  box-shadow: 0 0 0 0 black inset, -2vh 0 0 0 black inset, 0 0 2vh 0 black;
  transition: opacity 150ms linear 0s, transform 300ms ease-in-out 0s,
    box-shadow 300ms ease-in-out 0s, border-radius 300ms ease-in-out 300ms,
    background-color 300ms ease-in-out 0s;
}
.kodamaDiv:hover {
  opacity: 1;
}
.kodamaDiv:nth-of-type(3) {
  transition: opacity 150ms linear 0s, transform 300ms ease-in-out 10ms,
    box-shadow 300ms ease-in-out 10ms, border-radius 300ms ease-in-out 310ms,
    background-color 300ms ease-in-out 10ms;
}
.kodamaDiv:nth-of-type(4) {
  transition: opacity 150ms linear 0s, transform 300ms ease-in-out 20ms,
    box-shadow 300ms ease-in-out 20ms, border-radius 300ms ease-in-out 320ms,
    background-color 300ms ease-in-out 20ms;
}
.kodamaDiv:nth-of-type(5) {
  transition: opacity 150ms linear 0s, transform 300ms ease-in-out 30ms,
    box-shadow 300ms ease-in-out 30ms, border-radius 300ms ease-in-out 330ms,
    background-color 300ms ease-in-out 30ms;
}
.kodamaDiv:nth-of-type(6) {
  transition: opacity 150ms linear 0s, transform 300ms ease-in-out 40ms,
    box-shadow 300ms ease-in-out 40ms, border-radius 300ms ease-in-out 340ms,
    background-color 300ms ease-in-out 40ms;
}
.kodamaDiv:nth-of-type(7) {
  transition: opacity 150ms linear 0s, transform 300ms ease-in-out 50ms,
    box-shadow 300ms ease-in-out 50ms, border-radius 300ms ease-in-out 350ms,
    background-color 300ms ease-in-out 50ms;
}
.kodamaDiv:nth-of-type(8) {
  transition: opacity 150ms linear 0s, transform 300ms ease-in-out 60ms,
    box-shadow 300ms ease-in-out 60ms, border-radius 300ms ease-in-out 360ms,
    background-color 300ms ease-in-out 60ms;
}
.kodamaDiv:nth-of-type(9) {
  transition: opacity 150ms linear 0s, transform 300ms ease-in-out 70ms,
    box-shadow 300ms ease-in-out 70ms, border-radius 300ms ease-in-out 370ms,
    background-color 300ms ease-in-out 70ms;
}
.kodamaDiv:nth-of-type(10) {
  transition: opacity 150ms linear 0s, transform 300ms ease-in-out 80ms,
    box-shadow 300ms ease-in-out 80ms, border-radius 300ms ease-in-out 380ms,
    background-color 300ms ease-in-out 80ms;
}
.eyeDiv,
.mouthDiv {
  position: absolute;
  width: 1.5vh;
  height: 1.5vh;
  top: 5vh;
  left: 3vh;
  /* box-shadow: 0 0 .15vh .15vh black; */
  border-radius: 50%;
  background-color: black;
  transition: background-color 300ms ease-in-out 0s,
    transform 300ms ease-in-out 0s;
}
.eyeDiv:nth-of-type(2) {
  left: 10vh;
}
.mouthDiv {
  top: 10vh;
  left: 7vh;
}
.faceDiv {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: rotate(-45deg);
}
#menu {
  position: absolute;
  top: -7vh;
  width: 100%;
  color: #c5c5c5;
  text-align: center;
  /* font-family: sans-serif; */
  font-family: "Work Sans", sans-serif;
  font-size: 5vh;
  transition: color 300ms linear 0s;
  cursor: pointer;
}
#menu:hover {
  color: white;
}
.openKodama {
  animation: kodamaShake 500ms linear;
}
@keyframes kodamaShake {
  0% {
    transform: rotate(45deg);
  }
  70% {
    transform: rotate(0deg);
  }
  80% {
    transform: rotate(65deg);
  }
  90% {
    transform: rotate(25deg);
  }
  100% {
    transform: rotate(45deg);
  }
}

              
            
!

JS

              
                function changeKodamas() {
  var x = document.getElementsByClassName("kodamaDiv");
  var i;
  for (i = 0; i < x.length; i++) {
    x[i].style.boxShadow =
      "0 0 0 10vh black inset, -2vh 0 0 0 black inset, 0 0 2vh 0 #000000";
    x[i].style.backgroundColor = "black";
    x[i].style.transform = "rotate(" + (Math.random() * 10 + 40) + "deg)";
    x[i].style.borderRadius =
      Math.random() * 60 +
      40 +
      "% " +
      (Math.random() * 60 + 40) +
      "% " +
      (Math.random() * 60 + 40) +
      "% " +
      (Math.random() * 60 + 40) +
      "% " +
      "/ " +
      (Math.random() * 60 + 40) +
      "% " +
      (Math.random() * 60 + 40) +
      "% " +
      (Math.random() * 60 + 40) +
      "% " +
      (Math.random() * 60 + 40) +
      "%";
    x[i].getElementsByClassName("mouthDiv")[0].style.backgroundColor = "white";
    x[i].getElementsByClassName("eyeDiv")[0].style.backgroundColor = "white";
    x[i].getElementsByClassName("eyeDiv")[1].style.backgroundColor = "white";
  }
  setTimeout(function() {
    var x = document.getElementsByClassName("kodamaDiv");
    var i;
    for (i = 0; i < x.length; i++) {
      x[i].getElementsByClassName("mouthDiv")[0].style.transform =
        "translate(" +
        (Math.random() * 4 - 2) +
        "vh, " +
        (Math.random() * 4 - 2) +
        "vh)";
      x[i].getElementsByClassName("eyeDiv")[0].style.transform =
        "translate(" +
        (Math.random() * 2 - 1) +
        "vh, " +
        (Math.random() * 2 - 1) +
        "vh)";
      x[i].getElementsByClassName("eyeDiv")[1].style.transform =
        "translate(" +
        (Math.random() * 2 - 1) +
        "vh, " +
        (Math.random() * 2 - 1) +
        "vh)";

      x[i].getElementsByClassName("mouthDiv")[0].style.transform +=
        " scale(" + (Math.random() + 1) + ")";
      eyeScale = Math.random() + 1;
      x[i].getElementsByClassName("eyeDiv")[0].style.transform +=
        " scale(" + (Math.random() + 1) + ")";
      x[i].getElementsByClassName("eyeDiv")[1].style.transform +=
        " scale(" + (Math.random() + 1) + ")";
    }
  }, 500);

  setTimeout(function() {
    var x = document.getElementsByClassName("kodamaDiv");
    var i;
    for (i = 0; i < x.length; i++) {
      x[i].style.boxShadow =
        "0 0 0 0 black inset, -2vh 0 0 0 #c5c5c5 inset, 0 0 2vh 0 #575757";
      x[i].style.backgroundColor = "white";
      x[i].getElementsByClassName("mouthDiv")[0].style.backgroundColor =
        "black";
      x[i].getElementsByClassName("eyeDiv")[0].style.backgroundColor = "black";
      x[i].getElementsByClassName("eyeDiv")[1].style.backgroundColor = "black";
    }
  }, 700);
}
function kodamaFunc(e) {
  //console.log(e.target.index);
  if (e.target == document.getElementsByClassName("kodamaDiv")[4]) {
    var x = document.getElementsByClassName("kodamaDiv");
    var i;
    for (i = 0; i < x.length; i++) {
      x[i].className += " openKodama";
    }
    setTimeout(function() {
      for (i = 0; i < x.length; i++) {
        x[i].className = " kodamaDiv";
      }
    }, 500);
  }
  e.target.className = "kodamaDiv";
  setTimeout(function() {
    e.target.className += " openKodama";
  }, 10);
}
function smallerKomadas() {
  var x = document.getElementsByClassName("kodamaDiv");
  var i;
  for (i = 0; i < x.length; i++) {
    x[i].style.transform = "rotate(45deg) scale(.8)";
  }
}
function largerKomadas() {
  var x = document.getElementsByClassName("kodamaDiv");
  var i;
  for (i = 0; i < x.length; i++) {
    x[i].style.transform = "rotate(45deg)";
  }
}
changeKodamas();

              
            
!
999px

Console