Arrow bouncing to the bottom right corner in CSS - css

I need an arrow to slightly move (bounce) to the bottom right corner on hover, using CSS. I've used the code below and I like what it does however this only moves the arrow left/right. How do I amend it so that it moves slightly to the bottom as well? I've tried using 'translateY' but couldn't workout the exact pixel amount for the animation to be smooth.
I've tried using 'bounce' but actually 'swing' seems to look better.
What I'm looking for is the kind on animation of this page:
http://ianlunn.github.io/Hover/ (called 'Wobble to Bottom Right')
.arrow:hover{
-webkit-animation: swing 1s ease;
animation: swing 1s ease;
-webkit-animation-iteration-count: 1;
animation-iteration-count: 1;
}
#-webkit-keyframes swing
{
15%
{
-webkit-transform: translateX(5px);
transform: translateX(5px);
}
30%
{
-webkit-transform: translateX(-5px);
transform: translateX(-5px);
}
50%
{
-webkit-transform: translateX(3px);
transform: translateX(3px);
}
65%
{
-webkit-transform: translateX(-3px);
transform: translateX(-3px);
}
80%
{
-webkit-transform: translateX(2px);
transform: translateX(2px);
}
100%
{
-webkit-transform: translateX(0);
transform: translateX(0);
}
}
#keyframes swing
{
15%
{
-webkit-transform: translateX(5px);
transform: translateX(5px);
}
30%
{
-webkit-transform: translateX(-5px);
transform: translateX(-5px);
}
50%
{
-webkit-transform: translateX(3px);
transform: translateX(3px);
}
65%
{
-webkit-transform: translateX(-3px);
transform: translateX(-3px);
}
80%
{
-webkit-transform: translateX(2px);
transform: translateX(2px);
}
100%
{
-webkit-transform: translateX(0);
transform: translateX(0);
}
}

You have to use translate(x,y) instead of translateX(x) for 2d transformation as #fen1x mentioned in the comment above
Try this:
#keyframes hvr-wobble-to-bottom-right {
16.65% {
-webkit-transform: translate(8px, 8px);
transform: translate(8px, 8px);
}
33.3% {
-webkit-transform: translate(-6px, -6px);
transform: translate(-6px, -6px);
}
49.95% {
-webkit-transform: translate(4px, 4px);
transform: translate(4px, 4px);
}
66.6% {
-webkit-transform: translate(-2px, -2px);
transform: translate(-2px, -2px);
}
83.25% {
-webkit-transform: translate(1px, 1px);
transform: translate(1px, 1px);
}
100% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
}

Related

How to create floating image transition with css and react

I want to create a floating image transition with CSS and react,same like in Divi theme header images
enter image description here
https://divisupreme.com/features/
Try this:
.floating {
-webkit-animation: movebounce 5s linear infinite;
animation: movebounce 5s linear infinite;
}
#-webkit-keyframes movebounce {
0% {
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
50% {
-webkit-transform: translateY(20px);
transform: translateY(20px);
}
100% {
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
}
#keyframes movebounce {
0% {
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
50% {
-webkit-transform: translateY(20px);
transform: translateY(20px);
}
100% {
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
}
<div className='floating'><img src='YOUR_IMG' alt='' /></div>

Pause in infinitive CSS animation

I have created this arrow that bounces and I want to add a pause for like 2 seconds between the bounces. I found a couple of similar examples here but they didn't work for my arrow (changed the bouncing animation).
If i add the following I get a pause but only once:
-webkit-animation-delay: 2s; /* Safari 4.0 - 8.0 */
animation-delay: 2s;
Anyway, here is the code:
HTML:
<div class="btn-bottom"></div>
CSS:
.btn-bottom{
width: 48px;
height: 58px;
background: url("https://d30y9cdsu7xlg0.cloudfront.net/png/10897-200.png")
center center no-repeat;
background-size: 47px;
margin: auto;
top: 40px;
left: 0;
right: 0;
cursor: pointer;
-webkit-animation: bounce 2.5s infinite;
animation: bounce 2.5s infinite;
}
#-webkit-keyframes bounce {
0%, 20%, 50%, 80%, 100% {
-webkit-transform: translateY(0);
}
40% {
-webkit-transform: translateY(-30px);
}
60% {
-webkit-transform: translateY(-15px);
}
}
#-moz-keyframes bounce {
0%, 20%, 50%, 80%, 100% {
-moz-transform: translateY(0);
}
40% {
-moz-transform: translateY(-30px);
}
60% {
-moz-transform: translateY(-15px);
}
}
#keyframes bounce {
0%, 20%, 50%, 80%, 100% {
-webkit-transform: translateY(0);
-moz-transform: translateY(0);
-ms-transform: translateY(0);
-o-transform: translateY(0);
transform: translateY(0);
}
20%, 50%, 80%, 100% {
-webkit-transform: translateY(0);
-moz-transform: translateY(0);
-ms-transform: translateY(0);
-o-transform: translateY(0);
transform: translateY(0);
}
40% {
-webkit-transform: translateY(-30px);
-moz-transform: translateY(-30px);
-ms-transform: translateY(-30px);
-o-transform: translateY(-30px);
transform: translateY(-30px);
}
60% {
-webkit-transform: translateY(-15px);
-moz-transform: translateY(-15px);
-ms-transform: translateY(-15px);
-o-transform: translateY(-15px);
transform: translateY(-15px);
}
}
JSFIDDLE:
https://jsfiddle.net/92xmw541/
Easiest way is to make the duration of the animation longer (4s below) and use half of the animation time with the keyframes. The rest of the keyframes the object will be at rest.
.btn-bottom {
width: 48px;
height: 58px;
background: url("https://d30y9cdsu7xlg0.cloudfront.net/png/10897-200.png") center center no-repeat;
background-size: 47px;
margin: auto;
top: 40px;
left: 0;
right: 0;
cursor: pointer;
animation: bounce 4s infinite;
}
#keyframes bounce {
10%,
20%,
30%,
40%,
50% {
transform: translateY(0);
}
15% {
transform: translateY(-30px);
}
25% {
transform: translateY(-15px);
}
35% {
transform: translateY(-5px);
}
45% {
transform: translateY(-2px);
}
}
<div class="btn-bottom"></div>
Here is a pure Javascript solution I ended up with to achieve a delay between CSS animations (like animate.css).
function repeatAnimate(element, delay) {
delay = delay || 5000;
setTimeout(function () {
element.style.webkitAnimation = 'none';
setTimeout(function () {
element.style.webkitAnimation = '';
repeatAnimate(element, delay);
}, 10);
}, delay)
}
Usage:
$(function () {
var element = document.getElementsByClassName('btn-play')[0];
repeatAnimate(element, 2000);
});
In this case the animated and bounce classes are already present in the HTML markup.

CSS animation not working in IE11 and Edge

I have tried putting my keyframes at the top of my CSS, not in the media query, http-equiv set to IE=Edge, etc.
It's a fairly basic .png image used during website load with simple rotate/y animation shown in this fiddle code below.
.loader-background {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 99999999;
background-color: #eef0eb;
}
.loader {
position: absolute;
height: 50px;
width: auto;
top: calc(50% - 25px);
left: calc(50% - 25px);
-webkit-animation-name: loader-animate;
-webkit-animation-duration: 5s;
-webkit-animation-iteration-count: infinite;
animation-name: loader-animate;
animation-duration: 5s;
animation-iteration-count: infinite;
}
#-webkit-keyframes loader-animate {
25% {
-webkit-transform: rotatey(360deg);
transform: rotatey(360deg);
}
50% {
-webkit-transform: rotatex(360deg);
transform: rotatex(360deg);
}
75% {
-webkit-transform: rotatey(0deg);
transform: rotatey(0deg);
}
100% {
-webkit-transform: rotatex(0deg);
transform: rotatex(0deg);
}
}
#keyframes loader-animate {
25% {
-webkit-transform: rotatey(360deg);
transform: rotatey(360deg);
}
50% {
-webkit-transform: rotatex(360deg);
transform: rotatex(360deg);
}
75% {
-webkit-transform: rotatey(0deg);
transform: rotatey(0deg);
}
100% {
-webkit-transform: rotatex(0deg);
transform: rotatex(0deg);
}
}
<div class="loader-background">
<img src="https://s30.postimg.org/7dct7bspd/GTG_FB_Logo.png" class="loader"/>
</div>
Works perfectly in Chrome and FF but not in Edge and IE11.
simply use rotate(..)
Animation will be a little different, but it will work
OK, so I figured it myself. You need to set the x and y rotation in every stage definition of the keyframe. Chrome obviously does better at filling in the blanks... revised fiddle
#-webkit-keyframes loader-animate {
0% {
-webkit-transform: rotatex(0deg) rotatey(0deg);
transform: rotatex(0deg) rotatey(0deg);
}
25% {
-webkit-transform: rotatex(0deg) rotatey(360deg);
transform: rotatex(0deg) rotatey(360deg);
}
50% {
-webkit-transform: rotatex(360deg) rotatey(360deg);
transform: rotatex(360deg) rotatey(360deg);
}
75% {
-webkit-transform: rotatex(360deg) rotatey(0deg);
transform: rotatex(360deg) rotatey(0deg);
}
100% {
-webkit-transform: rotatex(0deg) rotatey(0deg);
transform: rotatex(0deg) rotatey(0deg);
}
}
#keyframes loader-animate {
0% {
-webkit-transform: rotatex(0deg) rotatey(0deg);
transform: rotatex(0deg) rotatey(0deg);
}
25% {
-webkit-transform: rotatex(0deg) rotatey(360deg);
transform: rotatex(0deg) rotatey(360deg);
}
50% {
-webkit-transform: rotatex(360deg) rotatey(360deg);
transform: rotatex(360deg) rotatey(360deg);
}
75% {
-webkit-transform: rotatex(360deg) rotatey(0deg);
transform: rotatex(360deg) rotatey(0deg);
}
100% {
-webkit-transform: rotatex(0deg) rotatey(0deg);
transform: rotatex(0deg) rotatey(0deg);
}
}

custom path animation with CSS

#keyframes fadeOutDownMed {
0% {
opacity: 1;
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0);
}
100% {
opacity: 0;
-webkit-transform: translateY(150px);
-ms-transform: translateY(150px);
transform: translateY(150px);
}
}
http://jsfiddle.net/iaezzy/99JbQ/
This works but the animation is straight down, I need it to fade out slant like \, or to a certain element wherever that might be, is that possible?
Thanks
Try append translateX to the transform attribute like this:
#keyframes fadeOutDownMed {
0% {
opacity: 1;
-webkit-transform: translateY(0) translateX(0);
-ms-transform: translateY(0) translateX(0);
transform: translateY(0) translateX(0);
}
100% {
opacity: 0;
-webkit-transform: translateY(150px) translateX(150);
-ms-transform: translateY(150px) translateX(150);
transform: translateY(150px) translateX(150);
}
}
Demo: http://jsfiddle.net/k7Wp4/

CSS3 animation on launch and on hover?

I have a little problem. I want that the following animation gets fired when the user visits the page AND when he hovers over the element (it's an image). Right now it just fires when visiting the page, but .animated:hover gets ignored? Any advice?
.animated, .animated:hover {
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
-ms-animation-fill-mode: both;
-o-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation: swing 4s;
-moz-animation: swing 4s;
-ms-animation: swing 4s;
-o-animation: swing 4s;
animation: swing 4s;
}
#-webkit-keyframes swing {
0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100% { -webkit-transform-origin: bottom center; }
0% { -webkit-transform: rotate(0deg); }
10% { -webkit-transform: rotate(15deg); }
20% { -webkit-transform: rotate(-10deg); }
30% { -webkit-transform: rotate(10deg); }
40% { -webkit-transform: rotate(-8deg); }
50% { -webkit-transform: rotate(8deg); }
60% { -webkit-transform: rotate(-5deg); }
70% { -webkit-transform: rotate(5deg); }
80% { -webkit-transform: rotate(-2deg); }
90% { -webkit-transform: rotate(2deg); }
100% { -webkit-transform: rotate(0deg); }
}
#-moz-keyframes swing {
0% { -moz-transform: rotate(0deg); }
10% { -moz-transform: rotate(15deg); }
20% { -moz-transform: rotate(-10deg); }
30% { -moz-transform: rotate(10deg); }
40% { -moz-transform: rotate(-8deg); }
50% { -moz-transform: rotate(8deg); }
60% { -moz-transform: rotate(-5deg); }
70% { -moz-transform: rotate(5deg); }
80% { -moz-transform: rotate(-2deg); }
90% { -moz-transform: rotate(2deg); }
100% { -moz-transform: rotate(0deg); }
}
#-o-keyframes swing {
0% { -o-transform: rotate(0deg); }
10% { -o-transform: rotate(15deg); }
20% { -o-transform: rotate(-10deg); }
30% { -o-transform: rotate(10deg); }
40% { -o-transform: rotate(-8deg); }
50% { -o-transform: rotate(8deg); }
60% { -o-transform: rotate(-5deg); }
70% { -o-transform: rotate(5deg); }
80% { -o-transform: rotate(-2deg); }
90% { -o-transform: rotate(2deg); }
100% { -o-transform: rotate(0deg); }
}
#keyframes swing {
0% { transform: rotate(0deg); }
10% { transform: rotate(15deg); }
20% { transform: rotate(-10deg); }
30% { transform: rotate(10deg); }
40% { transform: rotate(-8deg); }
50% { transform: rotate(8deg); }
60% { transform: rotate(-5deg); }
70% { transform: rotate(5deg); }
80% { transform: rotate(-2deg); }
90% { transform: rotate(2deg); }
100% { transform: rotate(0deg); }
}
.swing {
-webkit-transform-origin: bottom center;
-moz-transform-origin: bottom center;
-o-transform-origin: bottom center;
transform-origin: bottom center;
-webkit-animation-name: swing;
-moz-animation-name: swing;
-o-animation-name: swing;
animation-name: swing;
}
Nice animation, the hover is being cancelled out as its looking for change in the original CSS class, you can fix this by declaring the hover its on animation function.
/*PAGE LOAD ANIMATION*/
.animated{
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
-ms-animation-fill-mode: both;
-o-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation: swing 4s;
-moz-animation: swing 4s;
-ms-animation: swing 4s;
-o-animation: swing 4s;
animation: swing 4s;
}
#-webkit-keyframes swing {
0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100% { -webkit-transform-origin: bottom center; }
0% { -webkit-transform: rotate(0deg); }
10% { -webkit-transform: rotate(15deg); }
20% { -webkit-transform: rotate(-10deg); }
30% { -webkit-transform: rotate(10deg); }
40% { -webkit-transform: rotate(-8deg); }
50% { -webkit-transform: rotate(8deg); }
60% { -webkit-transform: rotate(-5deg); }
70% { -webkit-transform: rotate(5deg); }
80% { -webkit-transform: rotate(-2deg); }
90% { -webkit-transform: rotate(2deg); }
100% { -webkit-transform: rotate(0deg); }
}
#-moz-keyframes swing {
0% { -moz-transform: rotate(0deg); }
10% { -moz-transform: rotate(15deg); }
20% { -moz-transform: rotate(-10deg); }
30% { -moz-transform: rotate(10deg); }
40% { -moz-transform: rotate(-8deg); }
50% { -moz-transform: rotate(8deg); }
60% { -moz-transform: rotate(-5deg); }
70% { -moz-transform: rotate(5deg); }
80% { -moz-transform: rotate(-2deg); }
90% { -moz-transform: rotate(2deg); }
100% { -moz-transform: rotate(0deg); }
}
#-o-keyframes swing {
0% { -o-transform: rotate(0deg); }
10% { -o-transform: rotate(15deg); }
20% { -o-transform: rotate(-10deg); }
30% { -o-transform: rotate(10deg); }
40% { -o-transform: rotate(-8deg); }
50% { -o-transform: rotate(8deg); }
60% { -o-transform: rotate(-5deg); }
70% { -o-transform: rotate(5deg); }
80% { -o-transform: rotate(-2deg); }
90% { -o-transform: rotate(2deg); }
100% { -o-transform: rotate(0deg); }
}
#keyframes swing {
0% { transform: rotate(0deg); }
10% { transform: rotate(15deg); }
20% { transform: rotate(-10deg); }
30% { transform: rotate(10deg); }
40% { transform: rotate(-8deg); }
50% { transform: rotate(8deg); }
60% { transform: rotate(-5deg); }
70% { transform: rotate(5deg); }
80% { transform: rotate(-2deg); }
90% { transform: rotate(2deg); }
100% { transform: rotate(0deg); }
}
.swing {
-webkit-transform-origin: bottom center;
-moz-transform-origin: bottom center;
-o-transform-origin: bottom center;
transform-origin: bottom center;
-webkit-animation-name: swing;
-moz-animation-name: swing;
-o-animation-name: swing;
animation-name: swing;
}
/*HOVER ANIMIATION*/
.animated:hover{
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
-ms-animation-fill-mode: both;
-o-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation: swingHover 4s;
-moz-animation: swingHover 4s;
-ms-animation: swingHover 4s;
-o-animation: swingHover 4s;
animation: swingHover 4s;
}
#-webkit-keyframes swingHover {
0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100% { -webkit-transform-origin: bottom center; }
0% { -webkit-transform: rotate(0deg); }
10% { -webkit-transform: rotate(15deg); }
20% { -webkit-transform: rotate(-10deg); }
30% { -webkit-transform: rotate(10deg); }
40% { -webkit-transform: rotate(-8deg); }
50% { -webkit-transform: rotate(8deg); }
60% { -webkit-transform: rotate(-5deg); }
70% { -webkit-transform: rotate(5deg); }
80% { -webkit-transform: rotate(-2deg); }
90% { -webkit-transform: rotate(2deg); }
100% { -webkit-transform: rotate(0deg); }
}
#-moz-keyframes swingHover {
0% { -moz-transform: rotate(0deg); }
10% { -moz-transform: rotate(15deg); }
20% { -moz-transform: rotate(-10deg); }
30% { -moz-transform: rotate(10deg); }
40% { -moz-transform: rotate(-8deg); }
50% { -moz-transform: rotate(8deg); }
60% { -moz-transform: rotate(-5deg); }
70% { -moz-transform: rotate(5deg); }
80% { -moz-transform: rotate(-2deg); }
90% { -moz-transform: rotate(2deg); }
100% { -moz-transform: rotate(0deg); }
}
#-o-keyframes swingHover {
0% { -o-transform: rotate(0deg); }
10% { -o-transform: rotate(15deg); }
20% { -o-transform: rotate(-10deg); }
30% { -o-transform: rotate(10deg); }
40% { -o-transform: rotate(-8deg); }
50% { -o-transform: rotate(8deg); }
60% { -o-transform: rotate(-5deg); }
70% { -o-transform: rotate(5deg); }
80% { -o-transform: rotate(-2deg); }
90% { -o-transform: rotate(2deg); }
100% { -o-transform: rotate(0deg); }
}
#keyframes swingHover {
0% { transform: rotate(0deg); }
10% { transform: rotate(15deg); }
20% { transform: rotate(-10deg); }
30% { transform: rotate(10deg); }
40% { transform: rotate(-8deg); }
50% { transform: rotate(8deg); }
60% { transform: rotate(-5deg); }
70% { transform: rotate(5deg); }
80% { transform: rotate(-2deg); }
90% { transform: rotate(2deg); }
100% { transform: rotate(0deg); }
}
.swingHover {
-webkit-transform-origin: bottom center;
-moz-transform-origin: bottom center;
-o-transform-origin: bottom center;
transform-origin: bottom center;
-webkit-animation-name: swingHover;
-moz-animation-name: swingHover;
-o-animation-name: swingHover;
animation-name: swingHover;
}

Resources