Offset Rotate Values

In this example below you will see how to do a Offset Rotate Values with some HTML / CSS and Javascript

Different Values for offset-rotation, requires Chrome 55 as of 12/2016

Thumbnail
This awesome code was written by danwilson, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright danwilson ©
  • HTML
  • CSS
  • JavaScript
    <div>
  <div class="container auto" data-rotation="auto">
    <div class="obj"></div>
  </div>
  <div class="container deg" data-rotation="45deg">
    <div class="obj"></div>
  </div>
  <div class="container autodeg" data-rotation="auto 45deg">
    <div class="obj"></div>
  </div>
  <div class="container autotransform"  data-rotation="auto + transform:rotate(45deg)">
    <div class="obj"></div>
  </div>
  <div class="container" data-rotation="The Path">
    <svg viewBox="0 0 500 100">
      <path d="M10,100 C15,5 490,5 490,100" stroke-width="2" fill="none" stroke="#c9c9c9" id="theMotionPath"/>
    </svg>
  </div>
</div>

/*Downloaded from https://www.codeseek.co/danwilson/offset-rotate-values-ORbdjw */
    .obj {
  width: 50px;
  height: 30px;
  background: rgb(35,200,158);
  offset-path: path("M10,100 C15,5 490,5 490,100");
  animation: move 2s 0s infinite alternate linear;
}

.auto .obj {
  offset-rotate: auto;
}
.autodeg .obj {
  offset-rotate: auto 45deg;
}
.deg .obj {
  offset-rotate: 45deg;
}
.autotransform .obj {
  offset-rotate: auto;
  transform: rotate(45deg);
}

@keyframes move {
  100% { 
    offset-distance: 100%; 
  }
}






.container {
  width: 500px;
  background: rgba(0,150,250,.1);
  height: 100px;
  transform: scale(.64);
  transform-origin: 50% 0%;
  position: relative;
}
.container::after {
  position: absolute;
  bottom: .5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.4rem;
  content: attr(data-rotation);
  text-align: center;
}
body {
  overflow-x: hidden;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: sans-serif;
}
body > div {
  margin: 2em 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  column-count: 2;
  min-height: 100vh;
}

*,*::before,*::after {
  box-sizing: border-box;
}


/*Downloaded from https://www.codeseek.co/danwilson/offset-rotate-values-ORbdjw */
    

Comments