1

I am a web developer. for my client's website I need to put an effect on hover a specific div as shown in this website . when i hover on a div the background should change by rotating. how can i do this. I can do only ease effect for background change using css3 transition. is there any way to do the same without using jquery ?

see the scrrenshot enter image description here

droidev
  • 7,352
  • 11
  • 62
  • 94

2 Answers2

1

jsbin

I simulate your provide the animation without jquery. The key to achieve it that use the parent & chidl relation and understand the key point when animation play.

.hover{
  position: relative;
  width: 200px;
  height: 200px;
  background-color: #1cf;
}
.background{
  position: absolute;
  width: 100%;
  height: 100%;
  color: #fff;
  text-align: center;
  line-height:10;
  background-color: #c33;
  transition: all 0.3s;
  z-index: 2;
  font-size: 20px;
}
.content{
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: #fff;
  text-align: center;
  font-size: 20px;
  opacity: 0;
  line-height: 10;
  transform: scale(-1,1);
  transition: all 0.3s;
}
.hover:hover .background{
  transform: scale(-1,1);
  opacity: 0;
}

.hover:hover .content{
  transform: scale(1,1);
  opacity: 1;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div class="hover">
   <div class="background">
   This is background!!! 
   </div> 
   <div class="content">
      This is content!
   </div>
  </div>
</body>
</html>
Todd Mark
  • 1,847
  • 13
  • 25
0

    .spin{
        position: relative;
        top: 45%;
        left: 45%;
        height: 100px;
        width: 100px;
        background: red;
        box-shadow: 0 0 10px rgba(0,0,0,0.2);
        border-radius: 10px;
        border: 1px solid black;
        box-sizing: border-box;
        padding: 10px 30px;
        font-size: 25px;
        font-family: thin;
        text-align: center;
        transition: 1.5s;
    }
    .spin:hover{
        transform: rotate(360deg);
    }
    .flip{
        position: relative;
        top: 45%;
        left: 0%;
        height: 100px;
        width: 100px;
        background: red;
        box-shadow: 0 0 10px rgba(0,0,0,0.2);
        border-radius: 10px;
        border: 1px solid black;
        box-sizing: border-box;
        padding: 10px 30px;
        font-size: 25px;
        font-family: thin;
        text-align: center;
        transition: 1.5s;
    }
    .flip:hover{
        transform: rotateY(180deg);
        background: black;
    }
    @font-face {
        font-family: 'thin';
        src: url('http://fonts.gstatic.com/s/opensans/v10/cJZKeOuBrn4kERxqtaUH3VtXRa8TVwTICgirnJhmVJw.woff2');
    }
<div class='spin'>Spin me!</div>
<div class='flip'>Flip me!</div>
Oliver
  • 1,576
  • 1
  • 17
  • 31