17

I'm trying to do this shine effect operate automatically (without a: hover), every 5 seconds.

http://jsfiddle.net/AntonTrollback/nqQc7/

.icon:after {
  content: "";
  position: absolute;
  top: -110%;
  left: -210%;
  width: 200%;
  height: 200%;
  opacity: 0;
  transform: rotate(30deg);
  background: rgba(255, 255, 255, 0.13);
  background: linear-gradient(
    to right, 
    rgba(255, 255, 255, 0.13) 0%,
    rgba(255, 255, 255, 0.13) 77%,
    rgba(255, 255, 255, 0.5) 92%,
    rgba(255, 255, 255, 0.0) 100%
  );
}

.icon:hover:after {
  opacity: 1;
  top: -30%;
  left: -30%;
  transition-property: left, top, opacity;
  transition-duration: 0.7s, 0.7s, 0.15s;
  transition-timing-function: ease;
}
4
  • 1
    check stackoverflow.com/questions/23458640/… Dec 4, 2015 at 18:08
  • Can you state what's going wrong? Many people might be unwilling to click on the link, which presumably shows the problem, because it could go anywhere. Dec 4, 2015 at 18:09
  • I'm trying make the shine effect work automatically every X seconds, but now this effect only work with :hover. @GrahamAsher
    – Anderson
    Dec 4, 2015 at 18:13
  • Use animation instead of transition.
    – easwee
    Dec 4, 2015 at 19:12

1 Answer 1

33

You can create CSS animation like this DEMO

 @keyframes shine{
  10% {
    opacity: 1;
    top: -30%;
    left: -30%;
    transition-property: left, top, opacity;
    transition-duration: 0.7s, 0.7s, 0.15s;
    transition-timing-function: ease;
  }
  100% {
    opacity: 0;
    top: -30%;
    left: -30%;
    transition-property: left, top, opacity;
  }
}
7
  • @Anderson are you sure, i just got it that you want it to run every 5 sec but this is not it. I will figure it out soon. Dec 4, 2015 at 18:25
  • Do you know how can i disable that transition? Dec 4, 2015 at 18:26
  • Yes. I'm sure this help me.
    – Anderson
    Dec 4, 2015 at 18:32
  • 2
    Ok i think i got it. This one shine like you wanted every 5 sec jsfiddle.net/nqQc7/512 Dec 4, 2015 at 18:40
  • True. It is even better, actually.
    – Anderson
    Dec 4, 2015 at 18:44

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.