<section>
  <svg viewBox="0 0 300 300">
    <path d="M 0 100 L 200 150 L 300 150" fill="none" stroke="lightgrey"/>
  </svg>
  <div class="moving-element"></div>
</section>
.moving-element {
  offset-path: path('M 0 100 L 200 150 L 300 150');
  animation: move 4s ease-in-out infinite;
}

@keyframes move{
  0%{ offset-rotate: 15deg;}
  30%{ offset-rotate: 15deg;}
  60%{ offset-rotate: -20deg;}
  100%{ 
    offset-distance: 100%;
    offset-rotate: 0deg;
  }
}

.moving-element{
  background: lightblue;
  width: 50px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid slateblue;
  border-radius: 5px;
}

section{
  position: relative;
  width: 300px;
  height: 300px;
  margin: auto;
}
svg {
  position: absolute;
  stroke-width: 2px;
}

body{
  background: Azure;
  overflow-x: hidden;
}

*{
  box-sizing: border-box;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.