Floating button using css3 animation - html

I want to float the button from right bottom to right top. While floating, it comes to the middle left like shown in attached image. I have tried a few steps but it is not working properly. Any help is highly appreciated. Thank you!
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.animated.infinite {
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.bounceInUp {
-webkit-animation-name: bounceInUp;
animation-name: bounceInUp;
}
#keyframes bounceInUp {
from, 60%, 75%, 90%, to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
}
from {
opacity: 0;
-webkit-transform: translate3d(0, 3000px, 0);
transform: translate3d(0, 3000px, 0);
}
60% {
opacity: 1;
-webkit-transform: translate3d(0, -20px, 0);
transform: translate3d(0, -20px, 0);
}
75% {
-webkit-transform: translate3d(0, 10px, -1000);
transform: translate3d(0, 10px, -1000);
}
90% {
-webkit-transform: translate3d(0, -5px, 0);
transform: translate3d(0, -5px, 0);
}
to {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
<div style="float:right;" class="animated infinite bounceInUp">Button</div>

Instead of float: right, I have used position: absolute and right: for the desired effect. Check below snippet.
I have minimized the frames, please modify as per your needs.
.animated {
background-color: coral;
padding: 4px 10px;
position: absolute;
right: 0px;
-webkit-animation-duration: 5s;
animation-duration: 5s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.animated.infinite {
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.bounceInUp {
-webkit-animation-name: bounceInUp;
animation-name: bounceInUp;
}
#keyframes bounceInUp {
from {
right: 0px;
opacity: 0;
-webkit-transform: translateY(100vh);
transform: translateY(100vh);
}
60% {
opacity: 1;
right: 40%;
}
to {
right: 0px;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
}
<div class="animated infinite bounceInUp">Button</div>

Related

CSS keyframes animations behave as expected on desktop, but showing blank frames/jerky animation on mobile browsers

I am implementing a marquee style banner using css keyframes. It's working great in desktop (see here in action), but when I use the same implementation and view the site in mobile browsers the animation delay does not work as expected.
The following occurs on mobile browsers (chrome and safari):
I am using a negative animation delay so as to already be halfway through the marquee scroll but instead the text appears halfway up the screen.
Blocks of empty space appear then the text fills in after a lag.
The animation runs through once then doesn't skips a cycle then continues.
The two divs containing text overlap
I have tried using translate3d vs translateX, different animation durations and animation-delays, adding in webkit, ms, moz prefixes, inspecting on the mobile browser.
Example codepen link
Would appreciate any guidance!
<div class="marquee">
<div class="marqueeScroll">
<span>Countdown to our first city guide</span>
<span>•</span>
<span>
NYC comes out in 10 days 4 hours 30 minutes 2 seconds
</span>
<span>•</span>
<span>Countdown to our first city guide</span>
<span>•</span>
<span>
NYC comes out in 10 days 4 hours 30 minutes 2 seconds
</span>
<span>•</span>
</div>
<div class="marqueeScroll2">
<span>Countdown to our first city guide</span>
<span>•</span>
<span>
NYC comes out in 10 days 4 hours 30 minutes 2 seconds
</span>
<span>•</span>
<span>Countdown to our first city guide</span>
<span>•</span>
<span>
NYC comes out in 10 days 4 hours 30 minutes 2 seconds
</span>
<span>•</span>
</div>
</div>
.marquee {
background-color: black;
color: #fff;
height: 39px;
width: 100vh;
right: 100vh;
overflow: hidden;
-webkit-transform: rotate(270deg) translateY(-100vh);
transform: rotate(270deg) translateY(-100vh);
transform-origin: top right;
display: flex;
align-items: center;
position: -webkit-sticky;
position: sticky;
top: 0;
}
.marquee:hover {
cursor: pointer;
}
.marquee span {
padding-right: 18px;
}
.marqueeScroll, .marqueeScroll2 {
height: 20px;
white-space: nowrap;
font-size: 10px;
display: block;
-webkit-animation-duration: 70s;
-moz-animation-duration: 70s;
-o-animation-duration: 70s;
animation-duration: 70s;
-webkit-animation-timing-function: linear;
-moz-animation-timing-function: linear;
-o-animation-timing-function: linear;
animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
-o-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.marqueeScroll {
-webkit-animation-name: marquee;
-moz-animation-name: marquee;
-o-animation-name: marquee;
animation-name: marquee;
-webkit-animation-delay: -35s;
-moz-animation-delay: -35s;
-o-animation-delay: -35s;
animation-delay: -35s;
}
.marqueeScroll2 {
-webkit-animation-name: marquee2;
-moz-animation-name: marquee2;
-o-animation-name: marquee2;
animation-name: marquee2;
-webkit-animation-delay: -70s;
-moz-animation-delay: -70s;
-o-animation-delay: -70s;
animation-delay: -70s;
}
#-webkit-keyframes marquee {
0% {
-webkit-transform: translate3d(-100%, 0, 0);
}
100% {
-webkit-transform: translate3d(100%, 0, 0);
}
}
#-moz-keyframes marquee {
0% {
-moz-transform: translate3d(-100%, 0, 0);
}
100% {
-moz-transform: translate3d(100%, 0, 0);
}
}
#-o-keyframes marquee {
0% {
-o-transform: translate3d(-100%, 0, 0);
}
100% {
-o-transform: translate3d(100%, 0, 0);
}
}
#keyframes marquee {
0% {
transform: translate3d(-100%, 0, 0);
}
100% {
transform: translate3d(100%, 0, 0);
}
}
#-webkit-keyframes marquee2 {
0% {
-webkit-transform: translate3d(-200%, 0, 0);
}
100% {
-webkit-transform: translate3d(0%, 0, 0);
}
}
#-moz-keyframes marquee2 {
0% {
-moz-transform: translate3d(-200%, 0, 0);
}
100% {
-moz-transform: translate3d(0%, 0, 0);
}
}
#-o-keyframes marquee2 {
0% {
-o-transform: translate3d(-200%, 0, 0);
}
100% {
-o-transform: translate3d(0%, 0, 0);
}
}
#keyframes marquee2 {
0% {
transform: translate3d(-200%, 0, 0);
}
100% {
transform: translate3d(0%, 0, 0);
}
}

cant make a smooth rotation in rotate css

I'm trying to make a smooth landing with a rocket, but I'm not being able to do the rotation to make the position for landing in a smooth manner, could u guys please help me on this part of the code?
#keyframes rocket{
0%{
transform:translate(-10vw);
}
40%{
transform:translate(40vw);
}
70%{
transform:translate(70vw, -15vw) rotate(-90deg);
}
100%{
transform:translate(70vw, 0) rotate(-90deg);
}
}
.rocketA{
margin-top: 150px;
width: 80px;
height: 40px;
background-color: pink;
animation-name: rocket;
animation-duration: 4s;
animation-timing-function: ease-in-out;
animation-delay: 0s;
animation-iteration-count: 1;
animation-direction: normal;
-webkit-animation-fill-mode: forwards;
}
<div class='rocketA'></div>
If anyone finds this helpful here it goes the solution I found to make it better, thank for all the help.
SOLUTION
#keyframes rocket {
0% {
transform: translate(-10vw);
}
52% {
transform: translate(45vw);
}
52% {
transform: translate(45vw, -0vw) rotate(-5deg);
}
54% {
transform: translate(48vw, -0.5vw) rotate(-10deg);
}
56% {
transform: translate(51vw, -1vw) rotate(-15deg);
}
58% {
transform: translate(54vw, -1.5vw) rotate(-20deg);
}
60% {
transform: translate(57vw, -2vw) rotate(-25deg);
}
62% {
transform: translate(60vw, -2.5vw) rotate(-30deg);
}
64% {
transform: translate(63vw, -3vw) rotate(-35deg);
}
66% {
transform: translate(66vw, -3.5vw) rotate(-40deg);
}
68% {
transform: translate(69vw, -4vw) rotate(-45deg);
}
70% {
transform: translate(72vw, -4.5vw) rotate(-50deg);
}
72% {
transform: translate(75vw, -5vw) rotate(-55deg);
}
74% {
transform: translate(78vw, -5.5vw) rotate(-60deg);
}
76% {
transform: translate(81vw, -6vw) rotate(-65deg);
}
78% {
transform: translate(83vw, -6.5vw) rotate(-70deg);
}
80% {
transform: translate(85vw, -7vw) rotate(-75deg);
}
82% {
transform: translate(88vw, -7.5vw) rotate(-80deg);
}
84% {
transform: translate(91vw, -8.5vw) rotate(-85deg);
}
86%, 96% {
transform: translate(94vw, -9vw) rotate(-90deg);
}
96%, 100% {
transform: translate(94vw, 0) rotate(-90deg);
}
}
.rocketA {
margin-top: 100px;
width: 80px;
height: 40px;
background-color: pink;
animation-name: rocket;
animation-duration: 5s;
animation-timing-function: linear;
animation-delay: 0s;
animation-iteration-count: 1;
animation-direction: normal;
-webkit-animation-fill-mode: forwards;
}
<div class='rocketA'></div>
Use animation-timing-function: linear;
Demo
#keyframes rocket{
0%{
transform:translate(-10vw);
}
40%{
transform:translate(40vw);
}
70%{
transform:translate(70vw, -15vw) rotate(-90deg);
}
100%{
transform:translate(70vw, 5vw) rotate(-90deg);
}
}
.rocketA{
margin-top: 150px;
width: 80px;
height: 40px;
background-color: pink;
animation-name: rocket;
animation-duration: 4s;
animation-timing-function: linear;
animation-delay: 0s;
animation-iteration-count: 1;
animation-direction: normal;
-webkit-animation-fill-mode: forwards;
}
<div class='rocketA'></div>

CSS Animation not working (Bounce)

I am wondering why my bounce animation no working in JSFiddle but working on my development site. Please check what's wrong with this one. In my development site the arrow bounces but not rotated like what told inside my css class.
.active.ongoing::before {
content: "\f175";
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
text-decoration: inherit;
color: #56a4da;
font-size: 28px;
padding-right: 0.5em;
position: absolute;
top: 31px;
transform: rotate(41deg);
animation: bounce 2s infinite;
-moz-animation:bounce 2s infinite;
-ms-animation:bounce 2s infinite;
-webkit-animation: bounce 2s infinite;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css" rel="stylesheet"/>
<div class="active ongoing">
</div>
this animation is probably based on animate.css which probably included in your development site , which you didn't include or specify keyframes in jsfiddle
so you can add this to your css and it will work
#keyframes bounce {
from, 20%, 53%, 80%, to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
40%, 43% {
-webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
-webkit-transform: translate3d(0, -30px, 0);
transform: translate3d(0, -30px, 0);
}
70% {
-webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
-webkit-transform: translate3d(0, -15px, 0);
transform: translate3d(0, -15px, 0);
}
90% {
-webkit-transform: translate3d(0,-4px,0);
transform: translate3d(0,-4px,0);
}
}

Extend animation duration — CSS3

I've got the following animation. What I'm trying to do is when the animation reaches 50% I want it to stay there for 8 seconds.
If I change animation-duration: 3s; to 8s its is painfully slow.
And the transition-duration: 0.5s; doesn't seem to have any effect whatsoever.
I also tried adding animation-duration: 5s; to 50% {} but that doesn't do anything either.
Any suggestions on how to accomplish this?
html body div#size_cont div#dirt_specs {
-webkit-animation-name: dirt-specs1-anim;
-moz-animation-name: dirt-specs1-anim;
-o-animation-name: dirt-specs1-anim;
animation-name: dirt-specs1-anim;
-webkit-animation-timing-function: ease-in-out;
-moz-animation-timing-function: ease-in-out;
-o-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
-o-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
-o-transition-duration: 0.5s;
transition-duration: 0.5s;
-webkit-animation-duration: 3s;
-moz-animation-duration: 3s;
-o-animation-duration: 3s;
animation-duration: 3s;
transform: scale(1.4,1.4);
opacity: 0;
}
#-webkit-keyframes dirt-specs1-anim {
50% {
transform: scale(1.2,1.2);
opacity: 0.5;
}
100% {
opacity: 0;
}
}
#-moz-keyframes dirt-specs1-anim {
50% {
transform: scale(1.2,1.2);
opacity: 0.5;
}
100% {
opacity: 0;
}
}
#-o-keyframes dirt-specs1-anim {
50% {
transform: scale(1.2,1.2);
opacity: 0.5;
}
100% {
opacity: 0;
}
}
#keyframes dirt-specs1-anim {
50% {
transform: scale(1.2,1.2);
opacity: 0.5;
}
100% {
opacity: 0;
}
}
This is what you need to do in your animation frames:
#keyframes dirt-specs1-anim {
13.6% {
transform: scale(1.2, 1.2);
opacity: 0.5;
}
86.4% {
transform: scale(1.2, 1.2);
opacity: 0.5;
}
100% {
opacity: 0;
}
}
And simply set your animation-duration to 11s.
Explanation:
Since your original animation was 3 seconds long, and your requirement is to include a 8 second delay in the middle, the entire animation becomes 11 seconds.
This means that 1.5s goes into the first transition, 8s goes into the frozen segment, and 1.5s goes into the ending transition.
With that said, you need to get the % at which 1.5s is done out of 11s, which 1.5/11 = 0.136, hence the 13.6%.
The 86.4% is calculated from the reverse, 1 - 1.5/11 = 0.864, and this is needed because you want to maintain this animation state up (i.e., the frozen segment) until the last 1.5s of the animation.
See below for a working example:
div {
height: 150px;
width: 150px;
background: red;
-webkit-animation-name: dirt-specs1-anim;
-moz-animation-name: dirt-specs1-anim;
-o-animation-name: dirt-specs1-anim;
animation-name: dirt-specs1-anim;
-webkit-animation-timing-function: ease-in-out;
-moz-animation-timing-function: ease-in-out;
-o-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
-o-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-duration: 11s;
-moz-animation-duration: 11s;
-o-animation-duration: 11s;
animation-duration: 11s;
transform: scale(1.4, 1.4);
opacity: 0;
}
#-webkit-keyframes dirt-specs1-anim {
13.6% {
transform: scale(1.2, 1.2);
opacity: 0.5;
}
86.4% {
transform: scale(1.2, 1.2);
opacity: 0.5;
}
100% {
opacity: 0;
}
}
#-moz-keyframes dirt-specs1-anim {
13.6% {
transform: scale(1.2, 1.2);
opacity: 0.5;
}
86.4% {
transform: scale(1.2, 1.2);
opacity: 0.5;
}
100% {
opacity: 0;
}
}
#-o-keyframes dirt-specs1-anim {
13.6% {
transform: scale(1.2, 1.2);
opacity: 0.5;
}
86.4% {
transform: scale(1.2, 1.2);
opacity: 0.5;
}
100% {
opacity: 0;
}
}
#keyframes dirt-specs1-anim {
13.6% {
transform: scale(1.2, 1.2);
opacity: 0.5;
}
86.4% {
transform: scale(1.2, 1.2);
opacity: 0.5;
}
100% {
opacity: 0;
}
}
<div></div>

CSS works on Chrome but not Firefox

I tried a lot of things but nothing is working, idk if its a transform/translateX thing or not. I tried fading and it worked, but bouncing and the translateX is not working. I am currently using brakets software and I also tried sublime test 2. Please help.
Thanks.
/*animations*/
/******************
* Bounce in right *
*******************/
.animated {
-webkit-animation-duration: 1s;
-moz-animation-duration: 1s;
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
}
.slow{
-webkit-animation-duration: 2s;
-moz-animation-duration: 2s;
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
}
.slower{
-webkit-animation-duration: 3s;
-moz-animation-duration: 3s;
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
}
.slowest{
-webkit-animation-duration: 4s;
-moz-animation-duration: 4s;
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
}
.bounceInRight, .bounceInLeft, .bounceInUp, .bounceInDown{
opacity:0;
-webkit-transform: translateX(100px);
-moz-transform: translateX(100px);
}
.fadeInRight, .fadeInLeft, .fadeInUp, .fadeInDown{
opacity:0;
-webkit-transform: translateX(400px);
-moz-transform: translateX(400px);
}
.flipInX, .flipInY, .rotateIn, .rotateInUpLeft, .rotateInUpRight,
.rotateInDownLeft, .rotateDownUpRight, .rollIn{
opacity:0;
}
.lightSpeedInRight, .lightSpeedInLeft{
opacity:0;
-webkit-transform: translateX(400px);
-moz-transform: translateX(400px);
}
/***********
* bounceIn *
************/
#-webkit-keyframes bounceIn {
0% {
opacity: 0;
-webkit-transform: scale(.3);
}
50% {
opacity: 1;
-webkit-transform: scale(1.05);
}
70% {
-webkit-transform: scale(.9);
}
100% {
-webkit-transform: scale(1);
}
}
#-moz-keyframes bounceIn {
0% {
opacity: 0;
-moz-transform: scale(.3);
}
50% {
opacity: 1;
-moz-transform: scale(1.05);
}
70% {
-moz- transform: scale(.9);
}
100% {
-moz-transform: scale(1);
}
}
.bounceIn.go {
-webkit-animation-name: bounceIn;
-moz-animation-name: bounceIn;
}
/****************
* bounceInRight *
****************/
#-webkit-keyframes bounceInRight {
0% {
opacity: 0;
-webkit-transform: translateX(100px);
}
30%{
-webkit-transform: translateX(100px)
}
60% {
-webkit-transform: translateX(-10px);
}
80% {
-webkit-transform: translateX(5px);
}
100% {
opacity: 1;
-webkit-transform: translateX(0);
}
}
#-moz-keyframes bounceInRight {
0% {
opacity: 1;
-moz- transform: translateX(100px);
}
30%{
-moz- transform: translateX(100px)
}
60% {
-moz-transform: translateX(-10px);
}
80% {
-moz-transform: translateX(5px);
}
100% {
opacity: 1;
-moz-transform: translateX(0);
}
}
.bounceInRight.go {
-webkit-animation-name: bounceInRight;
-moz-animation-name: bounceInRight;
}
You need the unprefixed properties.
So for example:
.animated {
-webkit-animation-duration: 1s;
-moz-animation-duration: 1s;
animation-duration: 1s; // unprefixed
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
animation-duration: 1s; // unprefixed
}
Thank you for your help. I have found the answer. My html code had something wrong which was:
style='display:inline, it works on chrome but for Firefox and Safari you should use this: style='display:inline-block.
Thanks again.
At first, check your syntax. I have noticed that there are some "broken" properties, written '-moz- transform'. It should be one word.
Second, could you provide some HTML or a jsfiddle?
(I could not post it as a comment - not enough reputation to do that.)