2

enter image description here

I have created a snippet. I want to tilt that image to both side repeatedly to both side.

.demo{
  text-align:center;
  }
.demo img{
width:50%;
  }
<div class="demo">
  <img src="http://20dollarlogo.com/wp-content/uploads/2016/08/Logo_TV_2015.png" alt="Logo">
</div>
semuzaboi
  • 4,972
  • 5
  • 20
  • 35

2 Answers2

1

Check if this meets your requirement.

var repeater;
doWork();
function doWork() { 
 repeater = setTimeout(doWork, 1000);
 if( $('.demo .test').hasClass( "flip" )){
   $('.demo .test').removeClass('flip');  
 }
 else{
    $('.demo .test').addClass('flip');  
 }
}
.demo{
  text-align:center;
  }
.demo img{
width:50%;
  }

.flip {
        -moz-transform: scaleX(-1);
        -o-transform: scaleX(-1);
        -webkit-transform: scaleX(-1);
        transform: scaleX(-1);
        filter: FlipH;
        -ms-filter: "FlipH";
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="demo">
  <img class='test' src="http://20dollarlogo.com/wp-content/uploads/2016/08/Logo_TV_2015.png" alt="Logo">
</div>
Hudhaifa Yoosuf
  • 869
  • 2
  • 12
  • 28
1

You could play around with the transform: rotate(); to give you the tilt effect. This in conjucture with CSS animation should give you what you are looking for.

Best part about this solution is that its purely CSS power.

Codepen here

.demo img{
  width:50%;
  -webkit-transform: rotate(0deg); /* Chrome, Safari, Opera */
  transform: rotate(0deg);
  animation-name: tilt;
  animation-duration: 3s;
  animation-iteration-count: infinite;
}

@keyframes tilt {
  0% { transform: rotate(0deg); }
  20% { transform: rotate(7deg); }
  40% { transform: rotate(0deg); }
  80% { transform: rotate(-7deg); }
  100% { transform: rotate(0deg); }
}

Let me know if you have any doubts.

Nikhil Nanjappa
  • 6,454
  • 3
  • 28
  • 44