JSFiddle - React, Tailwind, and code Playground

by shs400

HTML

<h1>transform-origin</h1>
<!-- Rotate-->
<div class="card">
  <div class="box rotate">
    <div class="fill"></div>
  </div>
  <p>rotate(45deg)</p>
  <p>transform-origin: 0 0</p>
</div>
<div class="card">
  <div class="box rotate2">
    <div class="fill"></div>
  </div>
  <p>rotateX(45deg)</p>
  <p>transform-origin: 50% 50%</p>
</div>
<div class="card">
  <div class="box rotate3">
    <div class="fill"></div>
  </div>
  <p>rotateX(45deg)</p>
  <p>transform-origin: 100% 100%</p>
</div>

CSS

@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,400italic,600,700,800);
*, *:after, *:before {
  box-sizing: border-box;
}

body {
  background: #F5F3F4;
  margin: 0;
  padding: 10px;
  font-family: 'Open Sans', sans-serif;
  text-align: center;
}

h1 {
  color: #4c4c4c;
  font-weight: 600;
  border-bottom: 1px solid #ccc;
}

h2, h4 {
  font-weight: 400;
  color: #4d4d4d;
}

.card {
  display: inline-block;
  margin: 10px;
  background: #fff;
  padding: 15px;
  min-width: 200px;
  box-shadow: 0 3px 5px #ddd;
  color: #555;
}
.card .box {
  width: 100px;
  height: 100px;
  margin: auto;
  background: #ddd;
  cursor: pointer;
  box-shadow: 0 0 5px #ccc inset;
}
.card .box .fill {
  width: 100px;
  height: 100px;
  position: relative;
  background: #03A9F4;
  opacity: .5;
  box-shadow: 0 0 5px #ccc;
  transition: 0.3s;
}
.card p {
  margin: 25px 0 0;
}



.rotate:hover .fill {
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
  transform-origin: 0 0;
}

.rotate2:hover .fill {
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
  transform-origin: 50% 50%;
}

.rotate3:hover .fill {
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
  transform-origin: 100% 100%;
}