Skip to content
Advertisement

Rotate an element an a fixed axis

enter image description here

Any way to achieve something like this in CSS/JS or GSAP ?

Advertisement

Answer

A simple CSS example

div {
  height: 100px;
  width: 100px;
  position: relative;
  background: blue;
  border-radius: 10px;
}

span {
  height: 10px;
  width: 50%;
  left: 50%;
  top: calc(50% - 5px);
  position: absolute;
  background: white;
  border-radius: 10em;
  animation-name: spin;
  animation-duration: 2000ms;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
  transform-origin: left center;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
<div>
  <span></span>
</div>
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement