I want a Call active animation for a project of mine. I have created one but am not 100% satisfied with its animation. I am pasting my code here please help me create a nice call active animation. If you guys have any other animation suggestion please do fire away.ty Cheers.!
What I want is animation denoting that the user is talking to another person.
.rc_side_phone {
display: inline-block;
font-size: 34px;
width: 38px;
height: 40px;
background: rgba(94, 178, 2, 0.56);
color: #fff;
line-height: 40px;
border-radius: 7px;
background: #4CAF50;
margin-left: 11px;
margin-top: 8px;
}
.rc_side_phone i {
line-height: 45px;
margin-left: 4px;
}
.rc_side_phone:after {
position: absolute;
content: '';
border-right: 2px solid #ffffff;
width: 10px;
left: 34px;
top: 28px;
height: 12px;
border-radius: 50%;
z-index: 9;
transform: rotate(-44deg);
-webkit-transform: rotate(-44deg);
animation: onCall 1s steps(5) infinite;
-webkit-animation: onCall 1s steps(5) infinite;
animation-delay: 0s;
}
.rc_side_phone:before {
position: absolute;
content: '';
border-right: 2px solid #ffffff;
width: 16px;
left: 33px;
top: 23px;
height: 17px;
border-radius: 50%;
z-index: 9;
transform: rotate(-44deg);
-webkit-transform: rotate(-44deg);
animation: onCallTwo 1s steps(10) infinite;
-webkit-animation: onCallTwo 1s steps(10) infinite;
/* animation-delay: 1.5s; */
}
#keyframes onCall {
0% {
width: 10px;
left: 34px;
top: 28px;
height: 12px;
}
100% {
width: 18px;
left: 31px;
top: 24px;
height: 19px;
}
/*100%{width: 10px;left: 34px;top: 28px;height: 12px;}*/
}
#-webkit-keyframes onCall {
0% {
width: 10px;
left: 34px;
top: 28px;
height: 12px;
}
100% {
width: 18px;
left: 31px;
top: 24px;
height: 19px;
}
}
#keyframes onCallTwo {
0% {
width: 16px;
left: 33px;
top: 23px;
height: 17px;
}
100% {
width: 18px;
left: 35px;
top: 18px;
height: 23px;
}
}
#-webkit-#keyframes onCallTwo {
0% {
width: 16px;
left: 33px;
top: 23px;
height: 17px;
}
100% {
width: 18px;
left: 35px;
top: 18px;
height: 23px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<span class="rc_side_phone">
<i class="fa fa-phone"></i>
</span>
If you are looking for an incoming call animation, What about this?:
UPDATE:
I have added the active call animation to the snippet
UPDATE2:
Added wave animation, and linear wave animation
body {
display: flex;
flex-wrap: nowrap;
align-items: center;
justify-content: space-around;
}
.ringing_phone,
.active_phone,
.active_phone2 {
display: inline-block;
color: #fff;
border-radius: 50%;
background: #4CAF50;
padding: 5px;
width: 50px;
height: 50px;
text-align: center;
position: relative;
margin: 0 10px;
}
.ringing_phone i,
.active_phone i,
.active_phone2 i {
line-height: 50px;
font-size: 2.25em;
}
.ringing_phone i {
animation: shake 2s infinite cubic-bezier(.36, .07, .19, .97) both;
}
.active_phone:after {
position: absolute;
content: '';
top: 50%;
left: 50%;
background: rgba(255, 255, 255, 0.1);
transform: translateX(-50%) translateY(-50%);
border-radius: 50%;
padding: 0.5em;
animation: activeCall 2s ease-in-out infinite both;
}
.active_phone2:after {
content: '';
display: block;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: linear-gradient(to bottom, rgba(#e8a, 1), rgba(#def, 0) 80%, rgba(white, .5));
z-index: 11;
transform: translate3d(0, 0, 0);
}
.active_phone:before,
.active_phone2:before {
position: absolute;
content: '';
width: 100%;
height: 100%;
top: 0;
left: 0;
background: rgba(255, 255, 255, 0.1);
border-radius: 50%;
animation: activeCall2 4s linear infinite both;
}
.ringing_phone:after,
.ringing_phone:before {
position: absolute;
content: '';
opacity: 0;
border-right: 2px solid #ffffff;
width: 15px;
height: 15px;
left: 40%;
top: 28%;
border-radius: 50%;
transform: rotate(-40deg);
animation: fadeInOne 2s infinite both;
}
.ringing_phone:before {
width: 20px;
height: 20px;
left: 40%;
top: 20%;
animation: fadeInTwo 2s infinite both;
}
.active_phone2 i {
z-index: 10;
position: relative;
}
.active_phone2 .cover {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
overflow: hidden;
border-radius: 50%;
}
.wave,
.wave2 {
opacity: .4;
position: absolute;
top: 25%;
left: -15%;
background: white;
width: 130%;
height: 130%;
transform-origin: 50% 48%;
border-radius: 45%;
animation: drift 3000ms infinite linear;
opacity: 0.2;
}
.wave2 {
background: none;
border-radius: 35%;
top: 40%;
border: 2px solid white;
}
.wave2.two {
animation: drift 7000ms infinite linear;
opacity: 0.1;
top: 42%;
}
.wave2.three {
animation: drift 5000ms infinite linear;
opacity: 0.05;
top: 44%;
}
.wave.two {
animation: drift 7000ms infinite linear;
top: 30%;
opacity: 0.1;
}
.wave.three {
animation: drift 5000ms infinite linear;
opacity: 0.05;
top: 35%;
}
#keyframes drift {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#keyframes activeCall {
20% {
padding: 1em;
}
25% {
padding: 0.5em;
}
35% {
padding: 1.5em;
}
50% {
padding: 1em;
}
60% {
padding: 1.55em;
}
80% {
padding: 0.7em;
}
100% {
padding: 0.5em;
}
}
#keyframes activeCall2 {
0% {
padding: 0em;
background-color: rgba(76, 175, 80, 0);
}
25% {
padding: 1em;
background-color: rgba(76, 175, 80, 0.5);
transform: translateX(-1em) translateY(-1em);
}
26%,
100% {
padding: 0;
opacity: 0;
}
}
#keyframes shake {
5%,
45% {
transform: rotate3d(0, 0, 1, -7deg);
}
10%,
40% {
transform: rotate3d(0, 0, 1, 7deg);
}
15%,
25%,
35% {
transform: rotate3d(0, 0, 1, -7deg);
}
20%,
30% {
transform: rotate3d(0, 0, 1, 7deg);
}
51% {
transform: rotate3d(0, 0, 0, 0deg);
}
100% {
transform: rotate3d(0, 0, 0, 0deg);
}
}
#keyframes fadeInOne {
45% {
opacity: 0
}
100% {
opacity: 1
}
}
#keyframes fadeInTwo {
55% {
opacity: 0
}
100% {
opacity: 1
}
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div>
<h5>Active call v3</h5>
<span class="active_phone2">
<i class="fa fa-phone"></i>
<span class="cover">
<span class='wave2 one'></span>
<span class='wave2 two'></span>
<span class='wave2 three'></span>
</span>
</span>
</div>
<div>
<h5>Active call v2</h5>
<span class="active_phone2">
<i class="fa fa-phone"></i>
<span class="cover">
<span class='wave one'></span>
<span class='wave two'></span>
<span class='wave three'></span>
</span>
</span>
</div>
<div>
<h5>Active call</h5>
<span class="active_phone">
<i class="fa fa-phone"></i>
</span>
</div>
<div>
<h5>Incoming call</h5>
<span class="ringing_phone">
<i class="fa fa-phone"></i>
</span>
</div>
If you add opacity on your key frames, I think it will be more cute.
Jsfidde: https://jsfiddle.net/e6Lvsrk1/
.rc_side_phone {
display: inline-block;
font-size: 34px;
width: 38px;
height: 40px;
background: rgba(94, 178, 2, 0.56);
color: #fff;
line-height: 40px;
border-radius: 7px;
background: #4CAF50;
margin-left: 11px;
margin-top: 8px;
}
.rc_side_phone i {
line-height: 45px;
margin-left: 4px;
}
.rc_side_phone:after {
position: absolute;
content: '';
border-right: 2px solid #ffffff;
width: 10px;
left: 34px;
top: 28px;
height: 12px;
border-radius: 50%;
z-index: 9;
transform: rotate(-44deg);
-webkit-transform: rotate(-44deg);
animation: onCall 1s steps(5) infinite;
-webkit-animation: onCall 1s steps(5) infinite;
animation-delay: 0s;
}
.rc_side_phone:before {
position: absolute;
content: '';
border-right: 2px solid #ffffff;
width: 16px;
left: 33px;
top: 23px;
height: 17px;
border-radius: 50%;
z-index: 9;
transform: rotate(-44deg);
-webkit-transform: rotate(-44deg);
animation: onCallTwo 1s steps(10) infinite;
-webkit-animation: onCallTwo 1s steps(10) infinite;
/* animation-delay: 1.5s; */
}
#keyframes onCall {
0% {
width: 10px;
left: 34px;
top: 28px;
height: 12px;
opacity:0;
}
100% {
width: 18px;
left: 31px;
top: 24px;
height: 19px;
opacity:1
}
/*100%{width: 10px;left: 34px;top: 28px;height: 12px;}*/
}
#-webkit-keyframes onCall {
0% {
width: 10px;
left: 34px;
top: 28px;
height: 12px;
}
100% {
width: 18px;
left: 31px;
top: 24px;
height: 19px;
}
}
#keyframes onCallTwo {
0% {
width: 16px;
left: 33px;
top: 23px;
height: 17px;
opacity:1
}
100% {
width: 18px;
left: 35px;
top: 18px;
height: 23px;
opacity:0;
}
}
#-webkit-#keyframes onCallTwo {
0% {
width: 16px;
left: 33px;
top: 23px;
height: 17px;
}
100% {
width: 18px;
left: 35px;
top: 18px;
height: 23px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<span class="rc_side_phone">
<i class="fa fa-phone"></i>
</span>
I slightly modified your original version, giving it a shorter animation time, alternating it, and animating without steps.
.rc_side_phone {
display: inline-block;
font-size: 34px;
width: 38px;
height: 40px;
background: rgba(94, 178, 2, 0.56);
color: #fff;
line-height: 40px;
border-radius: 7px;
background: #4CAF50;
margin-left: 11px;
margin-top: 8px;
}
.rc_side_phone i {
line-height: 45px;
margin-left: 4px;
}
.rc_side_phone:after {
position: absolute;
content: '';
border-right: 2px solid #ffffff;
width: 10px;
left: 34px;
top: 28px;
height: 12px;
border-radius: 50%;
z-index: 9;
-webkit-transform: rotate(-44deg);
transform: rotate(-44deg);
-webkit-animation: onCall 0.5s infinite alternate;
animation: onCall 0.5s infinite alternate;
}
.rc_side_phone:before {
position: absolute;
content: '';
border-right: 2px solid #ffffff;
width: 16px;
left: 33px;
top: 23px;
height: 17px;
border-radius: 50%;
z-index: 9;
-webkit-transform: rotate(-44deg);
transform: rotate(-44deg);
-webkit-animation: onCallTwo 0.5s infinite alternate;
animation: onCallTwo 0.5s infinite alternate;
}
#-webkit-keyframes onCall {
0% {
width: 10px;
left: 34px;
top: 28px;
height: 12px;
}
100% {
width: 18px;
left: 31px;
top: 24px;
height: 19px;
}
}
#keyframes onCall {
0% {
width: 10px;
left: 34px;
top: 28px;
height: 12px;
}
100% {
width: 18px;
left: 31px;
top: 24px;
height: 19px;
}
}
#-webkit-keyframes onCallTwo {
0% {
width: 16px;
left: 33px;
top: 23px;
height: 17px;
}
100% {
width: 18px;
left: 35px;
top: 18px;
height: 23px;
}
}
#keyframes onCallTwo {
0% {
width: 16px;
left: 33px;
top: 23px;
height: 17px;
}
100% {
width: 18px;
left: 35px;
top: 18px;
height: 23px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<span class="rc_side_phone">
<i class="fa fa-phone"></i>
</span>
Related
Hi I was wondering if I could get any advice on how to do a animation such as this in react native: https://codepen.io/gayane-gasparyan/pen/jOmaBQK
It uses a mixture of keyframes, linear gradients but is a CSS based animation.
I have react-native-reanimated and native-base and can also leverage these modules if necessary.
Main CSS code:
.card {
background: #191c29;
width: var(--card-width);
height: var(--card-height);
padding: 3px;
position: relative;
border-radius: 6px;
justify-content: center;
align-items: center;
text-align: center;
display: flex;
font-size: 1.5em;
color: rgb(88 199 250 / 0%);
cursor: pointer;
font-family: cursive;
}
.card:hover {
color: rgb(88 199 250 / 100%);
transition: color 1s;
}
.card:hover:before, .card:hover:after {
animation: none;
opacity: 0;
}
.card::before {
content: "";
width: 104%;
height: 102%;
border-radius: 8px;
background-image: linear-gradient(
var(--rotate)
, #5ddcff, #3c67e3 43%, #4e00c2);
position: absolute;
z-index: -1;
top: -1%;
left: -2%;
animation: spin 2.5s linear infinite;
}
.card::after {
position: absolute;
content: "";
top: calc(var(--card-height) / 6);
left: 0;
right: 0;
z-index: -1;
height: 100%;
width: 100%;
margin: 0 auto;
transform: scale(0.8);
filter: blur(calc(var(--card-height) / 6));
background-image: linear-gradient(
var(--rotate)
, #5ddcff, #3c67e3 43%, #4e00c2);
opacity: 1;
transition: opacity .5s;
animation: spin 2.5s linear infinite;
}
#keyframes spin {
0% {
--rotate: 0deg;
}
100% {
--rotate: 360deg;
}
}
a {
color: #212534;
text-decoration: none;
font-family: sans-serif;
font-weight: bold;
margin-top: 2rem;
}
Can you please assist I need to set footer in the below image behind my scrollbar to show all the contents in the scrollbar.
Image:: enter image description here
I edited below css to remove the z-index and the footer is now behind the scrollbar records but now am facing an issue with the menu button all the menu pages are inactive as per the image below.
Image 2: enter image description here
CSS code::
.page-footer {
position: fixed;
z-index: 10; // I removed this
bottom: 0;
height: $footer-height;
min-width: 100vw;
.page-footer__background {
clip-path: polygon(0 64%, 100% 0, 100% 100%, 0% 100%);
background-image: url('../resources/images/picture-2.jpg');
background-size: cover;
background-position: center;
position: absolute;
width: 100%;
height: 100%;
}
.page-footer_background-svg {
width: 100%;
height: 100%;
fill: white;
}
.floating-action-button {
width: 57px;
height: 57px;
position: absolute;
top: -22px;
right: 20px;
border-radius: 100%;
border: 5px solid white;
background: white;
box-shadow: 4px 1px 10px rgba(0, 0, 0, 0.2);
.floating-action-button-inner {
width: $floating-action-button-size;
height: $floating-action-button-size;
background: white;
position: absolute;
border-radius: 100%;
top: -1px;
left: -1px;
cursor: pointer;
border: 1px solid $color-daimler-petrol-d2;
text-align: center;
}
.floating-action-button-sub-buttons {
margin: 0;
padding: 0;
position: absolute;
left: ($floating-action-button-size - $floating-action-sub-button-size) * 0.5;
top: -5px;
}
.floating-action-button-sub-buttons.fab-hidden {
height: 0;
overflow: hidden;
}
.floating-action-button-sub-button {
background: white;
width: $floating-action-sub-button-size;
height: $floating-action-sub-button-size;
border-radius: 100%;
margin: 0 0 $floating-action-sub-button-margin 0;
padding: 0;
list-style: none;
position: absolute;
text-align: center;
line-height: $floating-action-sub-button-size;
color: $color-daimler-petrol-d2;
cursor: pointer;
opacity: 0;
transform: translate3d(0, 30px, 0);
//z-index: 500 !important;
span:nth-child(1) {
transition: ease opacity 0.3s 0.1s;
opacity: 0;
position: absolute;
text-align: right;
right: $floating-action-sub-button-size;
width: 200px;
padding-right: 10px;
color: #FFFFFF;
}
span:nth-child(2) .icon {
font-size: 18px;
}
}
.floating-action-button-sub-buttons.fab-visible .floating-action-button-sub-button {
opacity: 1;
transform: translate3d(0, 0, 0);
span:nth-child(1) {
opacity: 1;
transition: ease opacity 0.3s 0.6s;
}
}
}
#for $i from 1 through 10 {
.floating-action-button-sub-button:nth-child(#{$i}) {
transition: all ease-out 0.4s #{0.1 * $i}s;
top: #{(strip-unit($floating-action-sub-button-size) + strip-unit($floating-action-sub-button-margin)) * $i * -1}px;
}
.floating-action-button-sub-buttons.fab-hidden .floating-action-button-sub-button:nth-last-child(#{$i}) {
transition: all ease-out 0.1s #{0.03 * $i}s;
}
}
.floating-action-button-burger {
position: relative;
transform: rotate(0deg);
transition: 0.2s ease-in-out;
cursor: pointer;
top: 18px;
left: 14px;
span {
display: block;
position: absolute;
height: 1px;
width: $floating-action-button-burger-width;
background: $color-daimler-petrol-d2;
opacity: 1;
left: 0;
transform: rotate(0deg);
transition: ease transform 0.2s, ease opacity 0.3s 0.2s, ease top 0.3s 0.2s;
}
}
.floating-action-button-inner {
span:nth-child(1) {
top: 0;
}
span:nth-child(2), span:nth-child(3) {
top: $floating-action-button-burger-margin;
}
span:nth-child(4) {
top: $floating-action-button-burger-margin * 2;
}
}
.floating-action-btn-active .floating-action-button-inner {
span {
transition: ease transform 0.2s 0.3s, ease opacity 0.3s, ease top 0.3s;
}
span:nth-child(1) {
top: $floating-action-button-burger-margin;
opacity: 0;
}
span:nth-child(2) {
transform: rotate(45deg);
}
span:nth-child(3) {
transform: rotate(-45deg);
}
span:nth-child(4) {
top: $floating-action-button-burger-margin;
opacity: 0;
}
}
.floating-action-button-pill {
position: absolute;
left: -29px;
top: 42px;
padding: 2px;
border: 1px solid $brand-primary;
background: white;
border-radius: 100%;
}
.floating-action-button-pill-inner {
padding: 5px 7px;
background: $brand-primary;
border-radius: 100%;
text-align: center;
line-height: 20px;
min-width: 30px;
min-height: 30px;
}
I've tried a few things on this, like switching out the svg for a png, I've stared at my formatting and can't see anything wrong with it, I'm not coming up with anything. I'm wondering if the CSS animation is maybe interfering with it somehow?
Here's the website with it working in other browsers, on Internet Explorer 11 the circle just remains a yellow circle at the end of the animation.
#rosette {
z-index: 99;
position: absolute;
background-color: crimson;
height: 100vh;
width: 100vw;
animation: rosette-anim 5s;
animation-fill-mode: forwards;
content: "";
transform-style: preserve-3d;
background: rgb(51, 55, 56);
top: 0px;
right: 0px;
transform: rotateY(0.5turn);
}
#keyframes rosette-anim {
95% {
position: absolute;
background: rgb(51, 55, 56);
height: 137px;
width: 142px;
border-radius: 70px;
transform: rotateY(2turn);
top: 4px;
right: 20px;
}
100% {
position: absolute;
height: 137px;
width: 142px;
border-radius: 70px;
transform: rotateY(3turn);
background: rgb(164, 132, 60) url('https://www.pottertour.co.uk/imagesAwards/lux-life-award-transparent-min.svg');
background-size: 139px 100px;
background-size: contain;
background-repeat: no-repeat;
background-position: center;
z-index: 1;
top: 4px;
right: 26px;
}
}
<div id="rosette"></div>
Animation and transition for pseudo-elements is not supported by IE11. You could create <div> and use ID to write CSS for it and avoid using pseudo. The sample code is like below:
#rosette {
z-index: 99;
position: absolute;
background-color: crimson;
height: 100vh;
width: 100vw;
animation: rosette-anim 5s;
animation-fill-mode: forwards;
content: "";
transform-style: preserve-3d;
background: rgb(51, 55, 56);
top: 0px;
right: 0px;
transform: rotateY(0.5turn);
}
#keyframes rosette-anim {
95% {
position: absolute;
background: rgb(51, 55, 56);
height: 137px;
width: 142px;
border-radius: 70px;
transform: rotateY(2turn);
top: 4px;
right: 20px;
}
100% {
position: absolute;
height: 137px;
width: 142px;
border-radius: 70px;
transform: rotateY(3turn);
background: rgb(164, 132, 60);
background-size: 139px 100px;
background-size: contain;
background-repeat: no-repeat;
background-position: center;
z-index: 1;
top: 4px;
right: 26px;
}
}
#before {
content: '';
position: absolute;
border-bottom: 90px solid rgb(164, 132, 60);
border-left: 50px solid transparent;
border-right: 50px solid transparent;
top: 95px;
right: 80px;
transform: translateZ(-1px) rotate(-140deg);
opacity: 0;
z-index: -1;
animation: change 5s;
animation-fill-mode: forwards;
}
#after {
content: '';
position: absolute;
border-bottom: 90px solid rgb(164, 132, 60);
border-left: 50px solid transparent;
border-right: 50px solid transparent;
top: 95px;
left: auto;
right: 10px;
transform: translateZ(-1px) rotate(140deg);
opacity: 0;
z-index: -1;
animation: change 5s;
animation-fill-mode: forwards;
}
#keyframes change {
99% {
opacity: 0;
}
100% {
opacity: 1;
}
}
<div id="rosette"><img src="https://www.pottertour.co.uk/imagesAwards/lux-life-award-transparent-min.svg" id="award" alt="My private Harry Potter tours won Lux Life magazine's award for best pop culture tour Edinburgh, they anointed it 'Truly magical', bless them."
/></div>
<div id="before"></div>
<div id="after"></div>
Result in IE11:
I used ::before pseudo element for background-image and I wrote another keyframe animation for animate ::before element. This works in IE11.
#rosette {
z-index: 99;
position: absolute;
background-color: crimson;
height: 100vh;
width: 100vw;
animation: rosette-anim 5s;
animation-fill-mode: forwards;
transform-style: preserve-3d;
background: rgb(51, 55, 56);
top: 0px;
right: 0px;
transform: rotateY(0.5turn);
}
#rosette:before {
content: "";
background-image: url('https://www.pottertour.co.uk/imagesAwards/lux-life-award-transparent-min.svg');
background-repeat: no-repeat;
background-position: center;
background-size: contain;
/* visibility: hidden; */
animation: rosette-before 5s;
animation-fill-mode: forwards;
display: inline-block;
height: 100%;
position: absolute;
width: 100%;
opacity: 0;
}
#keyframes rosette-anim {
95% {
position: absolute;
background: rgb(51, 55, 56);
height: 137px;
width: 142px;
border-radius: 70px;
transform: rotateY(2turn);
top: 4px;
right: 20px;
}
to {
position: absolute;
height: 137px;
width: 142px;
border-radius: 70px;
transform: rotateY(3turn);
background-color: rgb(164, 132, 60);
z-index: 1;
top: 4px;
right: 26px;
}
}
#keyframes rosette-before {
99% {
opacity: 0;
}
100% {
opacity: 1;
}
}
<div id="rosette"></div>
I'm playing round with CSS animation by trying to replicate the following new google ads logo - example.
What is the best way to add the bounce effect on the green ball?
My current animation:
#keyframes greenblock {
0% {
top: 0px;
}
50% {
top: 45px;
}
100% {
bottom: 0px;
}
}
My code (fiddle):
.wrap {
border: 1px solid red;
height: 300px;
width: 300px;
position: relative
}
.blue-shape {
position: absolute;
left: 100px;
top: 0px;
width: 45px;
height: 45px;
background: #4285F4;
display: block;
border-radius: 45px;
animation: blueblock 2s forwards;
transform-origin: top center;
}
.yellow-shape {
position: absolute;
left: 122px;
top: 0px;
width: 45px;
height: 45px;
background: #FBBC04;
display: block;
border-radius: 45px;
animation: yellowblock 2s forwards;
transform-origin: top center;
}
.green-ball {
position: absolute;
border-radius: 45px;
width: 45px;
height: 45px;
background: #34A853;
animation: greenblock 1.5s forwards;
}
#keyframes blueblock {
0% {
height: 45px;
}
25% {
height: 140px;
transform: rotate(0deg);
}
50% {
transform: rotate(-30deg);
}
100% {
height: 140px;
transform: rotate(-30deg);
}
}
#keyframes yellowblock {
0% {
height: 45px;
opacity: 0;
}
25% {
height: 140px;
transform: rotate(0deg);
opacity: 0;
}
50% {
transform: rotate(30deg);
}
100% {
height: 140px;
transform: rotate(30deg);
opacity: 100;
left: 122px;
}
}
#keyframes greenblock {
0% {
top: 0px;
}
50% {
top: 45px;
}
100% {
bottom: 0px;
}
}
<div class="wrap">
<div class="yellow-shape">
<div class="green-ball">
</div>
</div>
<div class="blue-shape">
</div>
</div>
I've tried with this animation
animation: greenblock .6s ease-in-out .5s forwards;
and this set of keyframes
#keyframes greenblock {
0% { top: 0px; }
75% { top: calc(100% - 55px); }
50%, 100% { top: calc(100% - 45px); }
}
Demo
.wrap {
border: 1px solid red;
height: 300px;
width: 300px;
position: relative
}
.blue-shape {
position: absolute;
left: 100px;
top: 0px;
width: 45px;
height: 45px;
background: #4285F4;
display: block;
border-radius: 45px;
animation: blueblock 2s forwards;
transform-origin: top center;
}
.yellow-shape {
position: absolute;
left: 122px;
top: 0px;
width: 45px;
height: 45px;
background: #FBBC04;
display: block;
border-radius: 45px;
animation: yellowblock 2s forwards;
transform-origin: top center;
}
.green-ball {
position: absolute;
border-radius: 45px;
width: 45px;
height: 45px;
background: #34A853;
animation: greenblock .6s ease-in-out .5s forwards;
}
#keyframes blueblock {
0% {
height: 45px;
}
25% {
height: 140px;
transform: rotate(0deg);
}
50% {
transform: rotate(-30deg);
}
100% {
height: 140px;
transform: rotate(-30deg);
}
}
#keyframes yellowblock {
0% {
height: 45px;
opacity: 0;
}
25% {
height: 140px;
transform: rotate(0deg);
opacity: 0;
}
50% {
transform: rotate(30deg);
}
100% {
height: 140px;
transform: rotate(30deg);
opacity: 100;
left: 122px;
}
}
#keyframes greenblock {
0% { top: 0px; }
75% { top: calc(100% - 55px); }
50%, 100% { top: calc(100% - 45px); }
}
<div class="wrap">
<div class="yellow-shape">
<div class="green-ball">
</div>
</div>
<div class="blue-shape">
</div>
</div>
I have this code: https://jsfiddle.net/e0u4sow1/6/
It works, I added a arrow beneath the text when you hover over the image. I want that arrow to slide in from the left to the center with a slow end and when you move your mouse away to slide right with a slow start. I spend 2 hours now trying many things to get this to work, but I give up. Can someone help me with this? also maybe a small explanation as to what part in the code makes the arrow slide in and out? I removed all code with arroweffect relations, so it's just the original effect with the arrow added
.media {
display: inline-block;
position: relative;
vertical-align: top;
}
.media__image {
display: block;
}
.media__body {
background: rgba(41, 128, 185, 0.7);
bottom: 0;
color: white;
font-size: 1em;
left: 0;
opacity: 0;
overflow: hidden;
padding: 3.75em 3em;
position: absolute;
text-align: center;
top: 0;
right: 0;
-webkit-transition: 0.6s;
transition: 0.6s;
}
.media__body:hover {
opacity: 1;
}
.media__body:after,
.media__body:before {
border: 1px solid rgba(255, 255, 255, 0.7);
bottom: 1em;
content: '';
left: 1em;
opacity: 0;
position: absolute;
right: 1em;
top: 1em;
-webkit-transform: scale(1.5);
-ms-transform: scale(1.5);
transform: scale(1.5);
-webkit-transition: 0.6s 0.2s;
transition: 0.6s 0.2s;
}
.media__body:before {
border-bottom: none;
border-top: none;
left: 2em;
right: 2em;
}
.media__body:after {
border-left: none;
border-right: none;
bottom: 2em;
top: 2em;
}
.media__body:hover:after,
.media__body:hover:before {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
.media__body h2 {
margin-top: 0;
}
.media__body p {
margin-bottom: 1.5em;
}
.arr {
display: inline-block;
padding: 1.2em;
box-shadow: 8px 8px 0 2px #FFF inset;
transform: rotate(135deg);
}
<h1>MR Cube</h1>
<div class="media">
<a href="http://www.google.nl/">
<img alt="" class="media__image" src="http://www.webwinkelsucces.nl/wp-content/uploads/2015/05/1112625-les-outils-de-test-et-d-integration-continue-open-source.jpg" />
<div class="media__body">
<h1>Lees meer</h1>
<div class="arr"></div>
</div>
</a>
As you didn't post your try to make the animation, it's hard to explain what you did wrong.
I made the animation in the following example adding translate on the arrow and removing it on hover. The transition decalration makes the animation between both states.
.media {
display: inline-block;
position: relative;
vertical-align: top;
}
.media__image {
display: block;
}
.media__body {
background: rgba(41, 128, 185, 0.7);
bottom: 0;
color: white;
font-size: 1em;
left: 0;
opacity: 0;
overflow: hidden;
padding: 3.75em 3em;
position: absolute;
text-align: center;
top: 0;
right: 0;
-webkit-transition: 0.6s;
transition: 0.6s;
}
.media__body:hover {
opacity: 1;
}
.media__body:after,
.media__body:before {
border: 1px solid rgba(255, 255, 255, 0.7);
bottom: 1em;
content: '';
left: 1em;
opacity: 0;
position: absolute;
right: 1em;
top: 1em;
-webkit-transform: scale(1.5);
-ms-transform: scale(1.5);
transform: scale(1.5);
-webkit-transition: 0.6s 0.2s;
transition: 0.6s 0.2s;
}
.media__body:before {
border-bottom: none;
border-top: none;
left: 2em;
right: 2em;
}
.media__body:after {
border-left: none;
border-right: none;
bottom: 2em;
top: 2em;
}
.media__body:hover:after,
.media__body:hover:before {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
.media__body h2 {
margin-top: 0;
}
.media__body p {
margin-bottom: 1.5em;
}
.arr {
display: inline-block;
padding: 1.2em;
box-shadow: 8px 8px 0 2px #FFF inset;
transform: translateX(250px) rotate(135deg);
transition: transform .8s ease-in;
}
.media__body:hover .arr {
transform: translateX(0) rotate(135deg);
transition-timing-function: ease-out;
}
<div class="media">
<a href="http://www.google.nl/">
<img alt="" class="media__image" src="http://www.webwinkelsucces.nl/wp-content/uploads/2015/05/1112625-les-outils-de-test-et-d-integration-continue-open-source.jpg" />
<div class="media__body">
<h1>Lees meer</h1>
<div class="arr"></div>
</div>
</a>
Note that you will need to add the vendor prefixes to the transition and transform properties for browser support (see canIuse for 2D transform and transitions)
I would also suggest you read up on MDN about transforms and transitions.