CSS "shine" effect

by Gerald Fullam

HTML

<div class="icon" id="my_button_div">
    <span class="icon-effect"></span>
</div>

<!--
Forked by:
Nicolas Gallagher - http://jsfiddle.net/KbNq7/
Chris Coyier - http://jsfiddle.net/chriscoyier/hk6z9/1/
-->

CSS

/* Icon */

.icon {
  display: block;
  width: 32px;
  height: 32px;
  background: red;
    
  position: relative;
  overflow: hidden;
}

/* "shine" element */
/* Could be a pseudo element but they lack support for CSS transitions in some browsers */

.icon .icon-effect {
  position: absolute;
  top: -110%;
  left: -210%;
  width: 200%;
  height: 200%;

  opacity: 0;
  
  background: rgba(255, 255, 255, 0.2);
  background: -moz-linear-gradient(
    left,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.1) 75%,
    rgba(255, 255, 255, 0.5) 90%,
    rgba(255, 255, 255, 0.0) 100%
  );
  background: -webkit-linear-gradient(
    top,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.1) 75%,
    rgba(255, 255, 255, 0.5) 90%,
    rgba(255, 255, 255, 0.0) 100%
  );
  background: -webkit-gradient(
    linear, left top, right top,
    color-stop(0%  ,rgba(255, 255, 255, 0.2)),
    color-stop(75% ,rgba(255, 255, 255, 0.2)),
    color-stop(90% ,rgba(255, 255, 255, 0.8)),
    color-stop(100%,rgba(255, 255, 255, 0.0))
  );
  background: -o-linear-gradient(
    top,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.1) 75%,
    rgba(255, 255, 255, 0.5) 90%,
    rgba(255, 255, 255, 0.0) 100%
  );
  background: -ms-linear-gradient(
    top,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.1) 75%,
    rgba(255, 255, 255, 0.5) 90%,6
    rgba(255, 255, 255, 0.0) 100%
  );
  background: linear-gradient(
    top,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.1) 75%,
    rgba(255, 255, 255, 0.5) 90%,
    rgba(255, 255, 255, 0.0) 100%
  );

  -webkit-transform: rotate(30deg);
     -moz-transform: rotate(30deg);
      -ms-transform: rotate(30deg);
       -o-transform: rotate(30deg);
          transform: rotate(30deg);
    
  -webkit-transition-property: left, top, opacity;
     -moz-transition-property: left, top, opacity;
      -ms-transition-property: left, top, opacity;
       -o-transition-property: left, top, opacity;
         ...

JavaScript

setInterval(function () {
    $('#my_button_div').toggleClass('triggered');
    setTimeout(function () {
        $('#my_button_div').toggleClass('triggered');
    }, 1000);
}, 5000);