samedi 18 juin 2016

flip card. Flip on both hover, and unflip when user uncovers


I have implemented a flip card of div, which works great when a user hovers on a div, however when they unhover on the div it doesn't unflip, but goes straight back to the way it was originally, not providing a smooth transition back.

can anyone help with making a smooth transition from the flip card back to what it originally looks like before the user hovers on the div.

Please see the code below.

Also, here is a jsfiddle to make the issue clearer.

css

.wrapper {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 0 20px;
}
.background-out,
.background-over {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}
.background-info {
  position: absolute;
  left: 200px;
  top: 0;
  width: 100%;
  height: 100%; 
  visibility: hidden;
  opacity: 0.2;
  transform-origin: 0% 50% 0px;
  transform: rotateY(-90deg);
  background-color: grey;
}
.background-info .text {
  padding: 5px;
}
.background-out {
  background-color: red;
}
.background-over {
  background-color: green;
  visibility: hidden;
  opacity: 0;
  transform-origin: 100% 50% 0px;
  transform: rotateY(-90deg);
}
.wrapper:hover .background-out {
  visibility: hidden;
}
.wrapper:hover .background-over,
.wrapper:hover .background-info {
  transform: translate3d(0px,0px,0px) rotateY(0deg);
  transition: opacity 600ms cubic-bezier(0.55, 0.31, 0.15, 0.93) 0ms,
  -moz-transform 600ms cubic-bezier(0.55, 0.31, 0.15, 0.93) 0ms,
  -webkit-transform 600ms cubic-bezier(0.55, 0.31, 0.15, 0.93) 0ms;
  visibility: visible;
  opacity: 1;
}

html

<div class="wrapper">
    <div class="background-out"></div>
    <div class="background-over"></div>
    <div class="background-info">
    <div class="text">Text 1</div>
  </div>
</div>

Aucun commentaire:

Enregistrer un commentaire