<h1>CSS Spinning Gradient Border</h1>
<h3>Spinning Border reverses on hover</3>
<div class="spin-me-round"></div>

<h4>By <a href="https://www.ashleyhitchcock.co.uk" target="_blank">Ash Hitchcock</a></h4>
//////////////////////////////////////////////
// CSS Spinning Gradient Border /////////////
// By Ash Hitchcock ashleyhitchcock.co.uk //
///////////////////////////////////////////

body {
  background-color: #eee;
  text-align: center;
  font-family: 'Open Sans', sans-serif;
  color: #333;
}

a {
  color: #333;  
}

.spinme() {
  display: block;
  width: 400px;
  height: 400px;
  margin: 50px auto;
  border-radius: 50%;
  background: #ffffff;
  background: linear-gradient(to right, #ffffff 10%, fade(#C61E1E,95%) 80%);
  position: relative;
  animation: spinani 1.8s infinite linear;
  transform: translateZ(0);
  transition: all 0.2s ease-in-out;
  box-shadow: 0px 0px 8px 1px rgba(0,0,0,0.75);

  &:before {
    background: #C61E1E;
    width: 90%;
    height: 90%;
    border-radius: 50%;
    content: '';
    margin: auto;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
  }
  
  &:hover {
    animation: spinanirev 1.8s infinite linear;
  }
  
}


@keyframes spinani {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes spinanirev {
  0% {
    transform: rotate(360deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

.spin-me-round {
  .spinme();
}
View Compiled

External CSS

  1. https://fonts.googleapis.com/css?family=Open+Sans:400,700

External JavaScript

This Pen doesn't use any external JavaScript resources.