Steve
Steve

Reputation: 1765

reverse an animation after div:hover

How do I:

Help appreciated, please.

@keyframes shift-up {
    from {margin-top: 0px;}
    to {margin-top: -10px;}
}
.owl-stage {padding-top: 10px;}
.owl-item:hover {
    animation-name: shift-up;
    animation-duration: 0.5s;
}
.owl-item {
  width: 100px;
  height: 100px;
  background-color: blue;
}
<div class="owl-stage">
  <div class="owl-item">
  
  </div>
</div>

Upvotes: 1

Views: 23

Answers (1)

ruleboy21
ruleboy21

Reputation: 6353

You can use transition instead of animation

.owl-stage {padding-top: 10px;}
.owl-item:hover {
    margin-top: -10px;
}
.owl-item {
  width: 100px;
  height: 100px;
  background-color: blue;
  transition: margin-top 0.5s ease-in-out;
}
<div class="owl-stage">
      <div class="owl-item">
      
      </div>
    </div>

Upvotes: 1

Related Questions