After checking out I implemented below code but the effect is not happening, don't know where its lacking..
<style>
.rotate {
-webkit-transition: -webkit-transform 0.4s ease-in-out;
-moz-transition: -moz-transform 0.4s ease-in-out;
-o-transition: -o-transform 0.4s ease-in-out;
-ms-transition: -ms-transform 0.4s ease-in-out;
transition: transform 0.4s ease-in-out;
cursor:pointer;
}
.rotate:hover {
color:#afafaf;
-webkit-transform: rotateZ(360deg);
-moz-transform: rotateZ(360deg);
-ms-transform: rotateZ(360deg);
-o-transform: rotateZ(360deg);
transform: rotateZ(360deg);
}
</style>
HTML
<div class="col-lg-6 col-md-6 col-sm-12">
<h2 align="center"> <icon class="icon icon-rocket icon-2x "> </icon> <br />
Build your Resume </h2>
</div>
Edit: changed the rotate CLASS from icon to parent
It will work with animation:
<div class="col-lg-6 col-md-6 col-sm-12">
<h2 align="center"> <icon class="icon icon-rocket icon-2x "> </icon> <br />
Build your Resume </h2>
</div>
CSS:
.rotate {
cursor:pointer;
}
.rotate:hover {
color:#afafaf;
-moz-animation: spin .4s 1 linear;
-o-animation: spin .4s 1 linear;
-webkit-animation: spin .4s 1 linear;
animation: spin .4s 1 linear;
}
#-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(359deg); }
}
#-moz-keyframes spin {
0% { -moz-transform: rotate(0deg); }
100% { -moz-transform: rotate(359deg); }
}
#-o-keyframes spin {
0% { -o-transform: rotate(0deg); }
100% { -o-transform: rotate(359deg); }
}
#-ms-keyframes spin {
0% { -ms-transform: rotate(0deg); }
100% { -ms-transform: rotate(359deg); }
}
#keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(359deg); }
}
Related
Blockquote
Hi people, i have an image gallery with grid and i want to put an Animista animation when user click on image , i tried to use hover on the class but there is an specificity error.
Blockquote
css:
img :hover{
.scale-up-center {
-webkit-animation: scale-up-center 0.7s cubic-bezier(0.550, 0.055, 0.675, 0.190) both;
animation: scale-up-center 0.7s cubic-bezier(0.550, 0.055, 0.675, 0.190) both;
}
#-webkit-keyframes scale-up-center {
0% {
-webkit-transform: scale(0.5);
transform: scale(0.5);
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
#keyframes scale-up-center {
0% {
-webkit-transform: scale(0.5);
transform: scale(0.5);
}
100% {
-webkit-transform: scale(3);
transform: scale(3);
}
}
}
html :
<div class="grid">div class="modulo">
<div class="producto" data-name="p-9">
<img class="scale-up-center"src="Img/Pastel.jpg" alt="Pastel">
<h3>Pastel</h3>
<div class="info">Las medidas son : alto:47 cm, ancho : 54 cm</div>
</div>
</div>
:hover selector is activated by moving mouse over an element. You need to use focus. To do that tabindex also needs to be set. Here is a demo:
.producto {
overflow: hidden
}
.producto img:focus {
animation: scale-up-center 0.7s cubic-bezier(0.550, 0.055, 0.675, 0.190) backwards;
}
.producto img:active {
animation: none;
}
#keyframes scale-up-center {
0% {
transform: scale(0.5);
}
100% {
transform: scale(3);
}
}
<div class="grid">
<div class="modulo">
<div class="producto" data-name="p-9">
<img tabindex="0" src="https://placekitten.com/100/100" alt="Pastel">
<h3>Pastel</h3>
<div class="info">Las medidas son : alto:47 cm, ancho : 54 cm</div>
</div>
</div>
</div>
I tried CSS scale transition ease-out not working, but the images do not scale yet.
An image is worth a thousand words. You will understanding easily the image. I also provide the snippet code box.
The 3 left images scale decreasing themselves and slide/ease from right to left and out and the 3 right images scale decreasing themselves and slide/ease from left to right and out.
Run the snippet box as you can see there is the space between a red image and the image do not scale. And the images are not aligned.
.sliding-images
{
align-items: center;
display: flex;
flex-flow: row nowrap;
height: 70%;
justify-content: center;
}
.sliding-images img
{
transition: transform 1s;
-webkit-transition: transform 1s;
width: 12%;
}
.sliding-images img:nth-child(1)
{
transform: scale(1.1) translateX(270%);
-webkit-transform: scale(1.1) translateX(270%);
transform-origin: right;
-webkit-transform-origin: right;
z-index: 1;
-webkit-animation: slide-left 0.15s ease-out both;
animation: slide-left 0.15s ease-out both;
}
.sliding-images img:nth-child(2)
{
transform: scale(1.2) translateX(178%);
-webkit-transform: scale(1.2) translateX(178%);
transform-origin: right;
-webkit-transform-origin: right;
z-index: 2;
-webkit-animation: slide-left 0.10s ease-out both;
animation: slide-left 0.10s ease-out both;
}
.sliding-images img:nth-child(3)
{
transform: scale(1.3) translateX(-87%);
transform: scale(1.3) translateX(-87%);
transform-origin: right;
-webkit-transform-origin: right;
z-index: 3;
-webkit-animation: slide-left 0.5s ease-out both;
animation: slide-left 0.5s ease-out both;
}
.sliding-images img:nth-child(4)
{
transform: scale(1.4);
-webkit-transform: scale(1.4);
z-index: 4;
}
.sliding-images img:nth-child(5)
{
transform: scale(1.3) translateX(-87%);
-webkit-transform: scale(1.3) translateX(-87%);
transform-origin: left;
-webkit-transform-origin: left;
z-index: 3;
-webkit-animation: slide-right 0.5s ease-out both;
animation: slide-right 0.5s ease-out both;
}
.sliding-images img:nth-child(6)
{
transform: scale(1.2) translateX(-178%);
-webkit-transform: scale(1.2) translateX(-178%);
transform-origin: left;
-webkit-transform-origin: left;
z-index: 2;
-webkit-animation: slide-right 0.10s ease-out both;
animation: slide-right 0.10s ease-out both;
}
.sliding-images img:nth-child(7)
{
transform: scale(1.1) translateX(-270%);
-webkit-transform: scale(1.1) translateX(-270%);
transform-origin: left;
-webkit-transform-origin: left;
z-index: 1;
-webkit-animation: slide-right 0.15s ease-out both;
animation: slide-right 0.15s ease-out both;
}
#-webkit-keyframes slide-left {
0% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-webkit-transform: translateX(-100px);
transform: translateX(-100px);
}
}
#keyframes slide-left {
0% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-webkit-transform: translateX(-100px);
transform: translateX(-100px);
}
}
#-webkit-keyframes slide-right
{
0% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-webkit-transform: translateX(100px);
transform: translateX(100px);
}
}
#keyframes slide-right
{
0% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-webkit-transform: translateX(100px);
transform: translateX(100px);
}
}
<div class="sliding-images">
<img src="https://via.placeholder.com/432x864/fdc34f/FEFEFE?text=1">
<img src="https://via.placeholder.com/432x864/3e72ff/FEFEFE?text=2">
<img src="https://via.placeholder.com/432x864/222222/FEFEFE?text=3">
<img src="https://via.placeholder.com/432x864/fe7b7b/FEFEFE?text=4">
<img src="https://via.placeholder.com/432x864/24d366/FEFEFE?text=5">
<img src="https://via.placeholder.com/432x864/afd33c/FEFEFE?text=6">
<img src="https://via.placeholder.com/432x864/41c8b8/FEFEFE?text=7">
</div>
You must use calc to calculate exact width and translateX positions.
see edited code snipped.
.sliding-images
{
position:absolute;
align-items: center;
display: flex;
flex-flow: row nowrap;
height: 70%;
justify-content: center;
}
.sliding-images img
{
transition: transform 1s;
-webkit-transition: transform 1s;
width: calc(100%/7);
}
.sliding-images img:nth-child(1)
{
transform-origin: right;
-webkit-transform-origin: right;
z-index: 1;
-webkit-animation: slide-left 0.15s ease-out both,scale11 0.1s both;
animation: slide-left 0.15s ease-out both,scale11 0.1s both;
}
.sliding-images img:nth-child(2)
{
transform: scale(1.2) translateX(178%);
-webkit-transform: scale(1.2) translateX(178%);
transform-origin: right;
-webkit-transform-origin: right;
z-index: 2;
-webkit-animation: slide-left 0.10s ease-out both,scale12 0.1s both;
animation: slide-left 0.10s ease-out both,scale12 0.1s both;
}
.sliding-images img:nth-child(3)
{
transform: scale(1.3) translateX(-87%);
transform: scale(1.3) translateX(-87%);
transform-origin: right;
-webkit-transform-origin: right;
z-index: 3;
-webkit-animation: slide-left 0.5s ease-out both,scale13 0.1s both;
animation: slide-left 0.5s ease-out both,scale13 0.1s both;
}
.sliding-images img:nth-child(4)
{
transform: scale(1.4);
-webkit-transform: scale(1.4);
z-index: 4;
}
.sliding-images img:nth-child(5)
{
transform: scale(1.3) translateX(-87%);
-webkit-transform: scale(1.3) translateX(-87%);
transform-origin: left;
-webkit-transform-origin: left;
z-index: 3;
-webkit-animation: slide-right 0.5s ease-out both,scale13 0.1s both;
animation: slide-right 0.5s ease-out both,scale13 0.1s both;
}
.sliding-images img:nth-child(6)
{
transform-origin: left;
-webkit-transform-origin: left;
z-index: 2;
-webkit-animation: slide-right 0.10s ease-out both,scale12 0.1s both;
animation: slide-right 0.10s ease-out both,scale12 0.1s both;
}
.sliding-images img:nth-child(7)
{
transform-origin: left;
-webkit-transform-origin: left;
z-index: 1;
-webkit-animation: slide-right 0.15s ease-out both,scale11 0.1s both;
animation: slide-right 0.15s ease-out both,scale11 0.1s both;
}
#-webkit-keyframes slide-left {
0% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-webkit-transform: translateX(calc(-100%/7));
transform: translateX(calc(-100%/7));
}
}
#keyframes slide-left {
0% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-webkit-transform: translateX(calc(-100%/7));
transform: translateX(calc(-100%/7));
}
}
#-webkit-keyframes slide-right
{
0% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-webkit-transform: translateX(calc(100%/7));
transform: translateX(calc(100%/7));
}
}
#keyframes slide-right
{
0% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-webkit-transform: translateX(calc(100%/7));
transform: translateX(calc(100%/7));
}
}
#keyframes scale11
{
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
}
#keyframes scale12
{
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(1.2);
transform: scale(1.2);
}
}
#keyframes scale13
{
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
}
<div class="sliding-images">
<img src="https://via.placeholder.com/432x864/fdc34f/FEFEFE?text=1">
<img src="https://via.placeholder.com/432x864/3e72ff/FEFEFE?text=2">
<img src="https://via.placeholder.com/432x864/222222/FEFEFE?text=3">
<img src="https://via.placeholder.com/432x864/fe7b7b/FEFEFE?text=4">
<img src="https://via.placeholder.com/432x864/24d366/FEFEFE?text=5">
<img src="https://via.placeholder.com/432x864/afd33c/FEFEFE?text=6">
<img src="https://via.placeholder.com/432x864/41c8b8/FEFEFE?text=7">
</div>
I use this code to create a blinking zoom-in and zoom-out image, but it only zoom-in and after that, it reset image and again zoom-in.
#keyframes blink {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(1.5);
transform: scale(1.5);
}
}
img {
transition: .3s ease-in;
animation: blink 1s;
animation-iteration-count: infinite;
}
JSFiddle
Easy solution would be:
#keyframes blink {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
50% {
-webkit-transform: scale(1.5);
transform: scale(1.5);
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
img {
transition: .3s ease-in;
animation: blink 1s;
animation-iteration-count: infinite;
}
So you just need in the end of animation make image same position as it is at start. : )
You have to animate it to the start point again. Like this:
#keyframes blink {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
50% {
-webkit-transform: scale(1.5);
transform: scale(1.5);
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
img {
transition: .3s ease-in;
animation: blink 1s;
animation-iteration-count: infinite;
}
I would like to make a simple animation, when the page loads, my logo should animate from the left side of the box to the right side. I have tried many versions, but haven't succeeded yet.
HTML
<body>
<div>
<img src="logo.png" alt="logo" style="width:170px;height:120px;">
</div>
</body>
CSS
div
{
width:640px;
height:175px;
background:blue;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
position:absolute;
}
div img
{
-webkit-transform: translate(3em,0);
-moz-transform: translate(3em,0);
-o-transform: translate(3em,0);
-ms-transform: translate(3em,0);
}
Try using keyframes.
div {
width: 50px;
height: 40px;
background: blue;
position: relative;
left: 500px;
-webkit-animation: slideIn 2s forwards;
-moz-animation: slideIn 2s forwards;
animation: slideIn 2s forwards;
}
#-webkit-keyframes slideIn {
0% {
transform: translateX(-900px);
}
100% {
transform: translateX(0);
}
}
#-moz-keyframes slideIn {
0% {
transform: translateX(-900px);
}
100% {
transform: translateX(0);
}
}
#keyframes slideIn {
0% {
transform: translateX(-900px);
}
100% {
transform: translateX(0);
}
}
<div></div>
You need to use animation instead of transition. Transition effects are triggered on certain events, for example a click which adds a class or a hover.
div img {
animation: example 1s ease-in-out forwards;
}
#keyframes example {
from {transform: transition(0,0)}
to {transform: transition(3em,0)}
}
Now you would of course have to add the prefixes for that, webkit, moz, etc.
For basic knowledge about keyframe animation in css3:
http://www.w3schools.com/css/css3_animations.asp
How do I do the inverse animation when I "hover off" the .child element (css3 only if possible)?
Fiddle
HTML:
<div class="child">
<i class="fa fa-video-camera spin" style="font-size:22px;"></i>
</div>
CSS:
.child:hover .spin{
-webkit-animation: spin 0.2s linear;
-moz-animation: spin 0.2s linear;
-o-animation: spin 0.2s linear;
animation: spin 0.2s linear;
}
#-moz-keyframes spin {
from {
-moz-transform: rotate(0deg);
}
to {
-moz-transform: rotate(360deg);
}
}
#-webkit-keyframes spin {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
#keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
The easiest way would be to use transition instead of keyframes:
.child .spin {
transition: transform .2s linear;
}
.child:hover .spin{
transform: rotate(360deg);
}
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="child">
<i class="fa fa-video-camera spin" style="font-size:22px;"></i>
</div>
Comes with auto-reverse built in. Much less code.
Don't use animation, use transition
<div class="camera"></div>
<style>
.camera{
height: 100px;
width: 50px;
background-color: red;
transition: 2s;
}
.camera:hover{
transform: rotate(360deg);
}
</style>
Fiddle
Well, you can do that. But you'll need a default animation too.
.child{
margin-top:20px;
margin-left:20px;
}
.child .spin{
-webkit-animation: spin 0.5s ease-in-out;
-moz-animation: spin 0.5s ease-in-out;
-o-animation: spin 0.5s ease-in-out;
animation: spin 0.5s ease-in-out;
}
.child:hover .spin{
-webkit-animation: spinh 0.5s ease-in-out;
-moz-animation: spinh 0.5s ease-in-out;
-o-animation: spinh 0.5s ease-in-out;
animation: spinh 0.5s ease-in-out;
}
#-moz-keyframes spin {
from {
-moz-transform: rotate(360deg);
}
to {
-moz-transform: rotate(0deg);
}
}
#-webkit-keyframes spin {
from {
-webkit-transform: rotate(360deg);
}
to {
-webkit-transform: rotate(0deg);
}
}
#keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#-webkit-keyframes spinh {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
#keyframes spinh {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
<div class="child">
<i class="fa fa-video-camera spin" style="font-size:22px;"></i>
</div>
See the working example.