Keyframes animation not working in Firefox - html

This animation is working perfectly in Safari and Chrome, but isn't working in Firefox.
I've tried a few things including -moz prefixes
Can anyone offer me advice on what's wrong here?
Here's the JSFiddle
HTML
<span class="awesome">
<span class="underline"></span>
<span class="underline2"></span>
awesome
</span>
CSS
span.awesome{
position: relative;
}
span.underline{
position: absolute;
top: 30px;
height: 1px;
background-color: black;
-webkit-animation: underline 2s linear infinite;
animation: underline 2s linear infinite;
}
span.underline2{
position: absolute;
top: 30px;
height: 1px;
background-color: black;
opacity: 0.2;
width: 110px;
}
#-webkit-keyframes underline{
0%{
width: 0px;
}
20%{
width: 0px;
}
28%{
width: 110px;
margin-left: 0;
}
36%{
width: 0px;
margin-left: 110px;
opacity: 0.8;
}
0%{
width: 0px;
}
}
#keyframes underline{
0%{
width: 0px;
}
20%{
width: 0px;
}
28%{
width: 110px;
margin-left: 0;
}
36%{
width: 0px;
margin-left: 110px;
opacity: 0.8;
}
0%{
width: 0px;
}
}

The problem was a typo – the last value read 0% instead of 100%
Don't need to specify -moz selectors for CSS3 animations in the latest versions of Firefox, but thanks for your suggestion, #Unykvis
Corrected CSS:
span.awesome{
position: relative;
}
span.underline{
position: absolute;
top: 30px;
height: 1px;
background-color: black;
-webkit-animation: underline 2s linear infinite;
animation: underline 2s linear infinite;
}
span.underline2{
position: absolute;
top: 30px;
height: 1px;
background-color: black;
opacity: 0.2;
width: 110px;
}
#-webkit-keyframes underline{
0%{
width: 0px;
}
20%{
width: 0px;
}
28%{
width: 110px;
margin-left: 0;
}
36%{
width: 0px;
margin-left: 110px;
opacity: 0.8;
}
100%{
width: 0px;
}
}
#keyframes underline{
0%{
width: 0px;
}
20%{
width: 0px;
}
28%{
width: 110px;
margin-left: 0;
}
36%{
width: 0px;
margin-left: 110px;
opacity: 0.8;
}
100%{
width: 0px;
}
}
Working JSFiddle

You need to add the -moz- to the keyframe animation and also to the selector.
Here is a working example: http://jsfiddle.net/ignaciocorreia/DxZps/4/
CSS:
span.underline{
position: absolute;
top: 30px;
height: 1px;
background-color: black;
-webkit-animation: underline 2s linear infinite;
-moz-animation: underline 2s linear infinite;
animation: underline 2s linear infinite;
}
#-moz-keyframes underline{
0%{
width: 0px;
}
20%{
width: 0px;
}
28%{
width: 110px;
margin-left: 0;
}
36%{
width: 0px;
margin-left: 110px;
opacity: 0.8;
}
0%{
width: 0px;
}
}

Related

Animation clash

I've worked out to attach two different animations to the same element, by using a comma, but the animation is finding compromise instead of executing each in successive order. How do I get one to execute and then the next when it's finished? What I want is right to left and, when finished, top to bottom. what I have is diagonal. Why?
.contact{
width: 0;
height: 0;
border: 50px solid transparent;
border-bottom: 70px solid red;
position: relative;
top: -50px;
}
.contact:after {
content: '';
position: absolute;
left: -50px;
top: 70px;
width: 0;
height: 0;
border: 50px solid
transparent;
border-top: 70px solid
red;
}
.contact{
margin-left: 200px;
top: 20px; transform:
rotate(90deg);
}
.contact {
animation: fish 4s linear
infinite, fish1 4s linear
infinite; animation-
duration: 4s; animation-iteration-
count: infinite; animation.
direction: alternate;
animation-timing-function: linear;
}
#keyframes fish {
from {right: 100px;} to {right: 1px; position: relative;}
}
#keyframes fish1 {
from {top: 2px;} to {top: 200px;}
}
<div class="contact"></div>
You can try this code
.contact{
width: 0;
height: 0;
border: 50px solid transparent;
border-bottom: 70px solid red;
position: relative;
top: 0;
margin-left: 0;
transform: rotate(90deg);
float:right;
}
.contact:after {
content: '';
position: absolute;
left: -50px;
top: 70px;
width: 0;
height: 0;
border: 50px solid transparent;
border-top: 70px solid red;
}
.contact {
animation: fish 4s linear infinite;
}
#keyframes fish {
0% {right: 0px; top: 0px;}
25% {right: 200px; top: 0px;}
50% {right: 200px; top: 200px;}
75% {right: 0px; top: 200px;}
100% {right: 0px; top: 0px;}
}
<div class="contact"></div>
Use Animation Keyframes, simply add a percentage for each keyframe. Also there is no need to declare multiple classes .contact, I've merged them into one
.contact{
width: 0;
height: 0;
border: 50px solid transparent;
border-bottom: 70px solid red;
position: relative;
margin-left: 200px;
top: 20px;
transform: rotate(90deg);
animation: fish 4s linear infinite;
animation-duration: 4s;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: linear;
}
.contact:after {
content: '';
position: absolute;
left: -50px;
top: 70px;
width: 0;
height: 0;
border: 50px solid transparent;
border-top: 70px solid
red;
}
#keyframes fish {
0% { right: 100px; }
50% { right: 1px; top: 2px; }
100% { top: 200px; }
}
<div class="contact"></div>

Have an element stay in the ending animation spot after ":hover"?

Whenever I hover on the first image, it moves to a different location. That is supposed to happen. But it comes back to it's original spot after un-hover. I need it to stay in the end location. If you understood that, can you help? Thanks in advance.`
I tried to have the code animation infinite, but that doesn't seem to work.
<html style="overflow: hidden;">
<meta name="viewport" content="width=device-width">
<head>
<script>
window.start();
function start(){
alert("This site is secure with SITELOCK TM. If this Website is hacked, the record will be loggled, and will be reported.");
console.log("This site is secure with SITELOCK TM. If this Website is hacked, the record will be loggled, and will be reported.")
}
</script>
<style>
#keyframes slide{
0%{
width: 50px;
}
100%{
width: 300px;
}
}
#keyframes fly{
0%{
top: 25;
left: 17;
width: 20;
}
100%{
top: 157;
left: 30;
}
}
#keyframes fade{
from{opacity: 0;}
to{opacity: 1;}
}
#keyframes fade2{
from{opacity: 0;}
to{opacity: 1;}
}
#keyframes goaway{
0%{
opacity: 1;
}
100%{
opacity: 0;
}
}
.nav:hover{
animation: slide 2s forwards;
}
.nav:hover > center > #home{
animation: fade2 2s forwards;
}
.nav:hover > center > #about{
animation: fade 2s forwards;
}
.nav:hover > #rocket{
animation: fly 2s forwards;
}
.nav:hover > #title{
animation: fade 7s forwards;
}
.nav:hover > center > #shop{
animation: fade 3s forwards;
}
.nav:hover > #menu_mark{
animation: goaway 1s forwards;
}
#image1:hover{
animation: move1 0.5s infinite;
}
#keyframes move1{
0%{
width: 160px;
top: 70px;
left: 200px;
}
50%{
width: 180px;
top: 50px;
left: 400px;
}
100%{
width: 200px;
top: 30px;
left: 600px;
}
}
#image1:hover ~ #image2{
animation: move2 0.5s infinite;
}
#keyframes move2{
0%{
left: 400px;
width: 180px;
top: 50px;
}
50%{
left: 600px;
width: 200px;
top: 30px;
}
100%{
width: 180px;
top: 50px;
left: 820px;
}
}
#image1: ~ #image3{
}
#image1:hover ~ #image4{
}
#image1:hover ~ #image5{
}
</style>
<script>
</script>
</head>
<link href="https://fonts.googleapis.com/css?family=Luckiest+Guy" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Thasadith" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Fjalla+One" rel="stylesheet">
<body style=" align-content: center; margin: 0; padding: 0; background-color: #404040; overflow-y: hidden;">
<div class="elements">
<img src="Image%201.png" id="image1" style="width: 160px; position: absolute; top: 70px; left: 220px; border-radius: 10px;">
<img src="Image%202.png" id="image2" style="width: 180px; position: absolute; top: 50px; left: 400px; border-radius: 10px;">
<img src="Image%203.png" id="image3" style="width: 200px; position: absolute; top: 30px; left: 600px; border-radius: 10px;">
<img src="Image%204.png" id="image4" style="width: 180px; position: absolute; top: 50px; left: 820px; border-radius: 10px;">
<img src="Image%205.png" id="image5" style="width: 160px; position: absolute; top: 70px; left: 1015px; border-radius: 10px;">
</div>
<div class="nav" style="background-color: #282829; height: 800px; width: 50px; box-shadow: 10px 0px 10px rgba(0, 0, 0, 0.4); margin-bottom: 10px; position: sticky; float: left;" >
<span id="title" style="display: inline-block; font-family: Thasadith; color: white; font-size: 40px; position: absolute; top: 150; left: 60px; opacity: 0;">MONOSPACE</span>
<center><span id="home" style="display: inline-block; padding-bottom: 25px; font-family: Fjalla One; color: white; font-size: 20px; padding-top: 250px; opacity: 0;">HOME</span><br>
<span id="about" style="display: inline-block; padding-bottom: 25px; font-family: Fjalla One; color: white; font-size: 20px; opacity: 0;">ABOUT</span><br>
<span id="shop" style="display: inline-block; padding-bottom: 25px; font-family: Fjalla One; color: white; font-size: 20px; opacity: 0;">SHOP</span><br></center>
<img id="menu_mark" src="LogoMakr_6Pr2go.png" style="width: 25px; position: absolute; top: 300px; left: 12.5px;">
<img id="rocket" src="LogoMakr_9Pl0y8.png" style="color: white; position: absolute; top: 25; left: 17; width: 20;">
</div>
</body>
</html>
You need two things. Firstly use forwards in the animation rather than infinite which is going to infinitely loop your animation. Secondly you need to maintain state. As soon as you mouse away that end state of the animation is lost and will repeat on re-hover. To avoid this use javascript to add a class on hover, this will handle the state for you.
const image = document.getElementById("image1");
const onHover = (e) => {
event.target.classList.add("hovered");
console.log('image hovered');
event.target.removeEventListener("mouseenter", onHover)
};
image.addEventListener("mouseenter", onHover)
#image1 {
width: 100px;
height: 100px;
background: blue
}
#image1.hovered {
animation: move1 0.5s forwards;
}
#keyframes move1{
0%{
width: 160px;
top: 70px;
left: 200px;
}
50%{
width: 180px;
top: 50px;
left: 400px;
}
100%{
width: 200px;
top: 30px;
left: 600px;
}
}
<div id="image1">
</div>
Try adding a timing for your animation:
.nav:hover > center > #home{ animation: fade2 2s ease-in-out forwards; }
I never use to/from, I always use 0%/100% you can do more things in that way.
Tell me if it works because I use my keyframes like this.

CSS animation move didn't work

I wanted to make an image of arrow moving so that readers know they can scroll down to read more content. I tried to do that with the animation in CSS but it didn't work.
section.scrollDownContainer {
width: 100%;
position: absolute;
top: 65px;
}
section.scrollDownContainer img {
display: block;
box-shadow: 5px 5px 5px #333333;
margin: auto;
-webkit-animation: arrowmove 0.5s forwards;
-moz-animation: arrowmove 0.5s forwards;
-ms-animation: arrowmove 0.5s forwards;
-o-animation: arrowmove 0.5s forwards;
animation: arrowmove 0.5s forwards;
}
#-webkit-keyframes arrowmove {
0% {
left: 0px;
top: 0px;
}
50% {
left: 0px;
top: 50px;
}
100% {
left: 0px;
top: 0px;
}
}
#-moz-keyframes arrowmove {
0% {
left: 0px;
top: 0px;
}
50% {
left: 0px;
top: 50px;
}
100% {
left: 0px;
top: 0px;
}
}
#-ms-keyframes arrowmove {
0% {
left: 0px;
top: 0px;
}
50% {
left: 0px;
top: 50px;
}
100% {
left: 0px;
top: 0px;
}
}
#-o-keyframes arrowmove {
0% {
left: 0px;
top: 0px;
}
50% {
left: 0px;
top: 50px;
}
100% {
left: 0px;
top: 0px;
}
}
#keyframes arrowmove {
0% {
left: 0px;
top: 0px;
}
50% {
left: 0px;
top: 50px;
}
100% {
left: 0px;
top: 0px;
}
}
<section class="scrollDownContainer">
<img src="./image/arrow.png">
</section>
Can anyone tell me why? Thank you.
You can use transform: translateY(...) in keyframes
section.scrollDownContainer {
width: 100%;
position: absolute;
top: 65px;
}
section.scrollDownContainer img {
display: block;
margin: auto;
animation: arrowmove 0.5s infinite;
}
#keyframes arrowmove {
0% {
transform: translateY(0%);
}
50% {
transform: translateY(50%);
}
100% {
transform: translateY(0%);
}
}
<section class="scrollDownContainer">
<img src="https://upload.wikimedia.org/wikipedia/en/f/f1/Down_Arrow_Icon.png" width="50px" height="50px">
</section>
The left: and top: properties of the animation will have no effect on your image because the image CSS does not contain a position property.
Add position: relative; or position: absolute; to the CSS for the image...
section.scrollDownContainer img {
position: relative; /* <------------------- added */
display: block;
box-shadow: 5px 5px 5px #333333;
margin: auto;
-webkit-animation: arrowmove 0.5s forwards;
-moz-animation: arrowmove 0.5s forwards;
-ms-animation: arrowmove 0.5s forwards;
-o-animation: arrowmove 0.5s forwards;
animation: arrowmove 0.5s forwards;
}
The animation should then function.
Using left:, right:, top:, or bottom: in CSS requires the element to also have a position property.

Make Button Bounce with CSS3

I am trying to make this button bounce with CSS3
.order {
position: absolute;
top: 50px;
left: 50px;
width: 75px;
line-height: 75px;
text-align:center;
opacity: 1;
background: green;
color:#fff;
border-radius:50%;
}
<div class="order">Order</div>
I would like it to bounce towards the screen (on the Z axis) up and down.
You can use a keyframe animation to animate the scale ratio and make your button bounce:
.order {
position: absolute;
top: 50px;
left: 50px;
width: 75px;
line-height: 75px;
text-align:center;
opacity: 1;
background: green;
color:#fff;
border-radius:50%;
animation: bounce .3s infinite alternate;
}
#keyframes bounce {
to { transform: scale(1.2); }
}
<div class="order">Order</div>
Iteration count:
If you want to stop the animation after a number of "bounces", you can use animation-iteration-count (use an even number of iterations otherwise the animation will snap on the last iteration) :
.order {
position: absolute;
top: 50px;
left: 50px;
width: 75px;
line-height: 75px;
text-align:center;
opacity: 1;
background: green;
color:#fff;
border-radius:50%;
animation: bounce .3s infinite alternate;
animation-iteration-count: 8;
}
#keyframes bounce {
to { transform: scale(1.2); }
}
<div class="order">Order</div>
try this css
.order {
background:url("http://onestudio.id-staging.com/_BUILD/Dominos/BANNERS/C3%20Digital%20Midweek%20Rescue/Wide%20Skyscraper/images/order.png");
background-size: cover;
position: absolute;
top:50px;
left:50px;
width: 75px;
height: 75px;
z-index:1;
opacity:1;
}
#keyframes fade {
from { top:40px;
left:40px;
width: 100px;
height: 100px; }
50% { top:50px;
left:50px;
width: 75px;
height: 75px; }
to { top:40px;
left:40px;
width: 100px;
height: 100px; }
}
#-webkit-keyframes fade {
from { top:40px;
left:40px;
width: 100px;
height: 100px; }
50% { top:50px;
left:50px;
width: 75px;
height: 75px; }
to { top:40px;
left:40px;
width: 100px;
height: 100px; }
}
.blink {
animation:fade 1000ms infinite;
-webkit-animation:fade 1000ms infinite;
}
try this html
<div class="order blink"></div>
The answer posted by web-tiki, would be the best one to use, still I have a different approach becoz you have already used position:absolute.
See this FIDDLE
you need to animate height and width for button using keyframe.
.order {
background: url("http://onestudio.id-staging.com/_BUILD/Dominos/BANNERS/C3%20Digital%20Midweek%20Rescue/Wide%20Skyscraper/images/order.png") no-repeat;
position: absolute;
background-size: cover;
top: 50px;
left: 50px;
width: 75px;
height: 75px;
z-index: 1;
opacity: 1;
-webkit-animation: mymove 1s infinite;
/* Chrome, Safari, Opera */
animation: mymove 1s infinite;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove {
0% {
height: 75px;
width: 75px;
}
50% {
height: 100px;
width: 100px;
}
100% {
height: 75px;
width: 75px;
}
}
/* Standard syntax */
#keyframes mymove {
0% {
height: 75px;
width: 75px;
}
50% {
height: 100px;
width: 100px;
}
100% {
height: 75px;
width: 75px;
}
}
<div class="order"></div>
Edit:
To add further, you can also animate left and top to 38px both so the
button doesn't look like deviating from original position see this
Fiddle
.order {
background: url("http://onestudio.id-staging.com/_BUILD/Dominos/BANNERS/C3%20Digital%20Midweek%20Rescue/Wide%20Skyscraper/images/order.png") no-repeat;
position: absolute;
background-size: cover;
top: 50px;
left: 50px;
width: 75px;
height: 75px;
z-index: 1;
opacity: 1;
-webkit-animation: mymove 1s infinite;
/* Chrome, Safari, Opera */
animation: mymove 0.5s 2;
}
/* Standard syntax */
#keyframes mymove {
0% {
height: 75px;
width: 75px;
left: 50px;
top: 50px;
}
50% {
height: 100px;
width: 100px;
left: 38px;
top: 38px;
}
100% {
height: 75px;
width: 75px;
left: 50px;
top: 50px;
}
}
<div class="order"></div>
You can animate(bounce) like following:
CSS:
.order {
background:url("http://onestudio.id-staging.com/_BUILD/Dominos/BANNERS/C3%20Digital%20Midweek%20Rescue/Wide%20Skyscraper/images/order.png");
position: absolute;
top:50px;
left:50px;
width: 75px;
height: 75px;
z-index:1;
opacity:1;
animation: myfirst 2s infinite;
-webkit-animation: myfirst 2s infinite;
}
#-webkit-#keyframes myfirst {
0% {
transform: scale(1);
}
50% {
transform: scale(1.5);
}
100% {
transform: scale(1);
}
}
#keyframes myfirst {
0% {
transform: scale(1);
}
50% {
transform: scale(1.5);
}
100% {
transform: scale(1);
}
}
Check Fiddle

Div always facing the screen inside a rotateY div

This is my code:
html
<div id="back">
<div id="right_text">TEST</div>
<div id="left_text">TEST2</div>
</div>
<div id="mid"></div>
css
#mid {
border: 1px solid black;
height: 100px;
width: 100px;
-webkit-animation: rotate linear 5s;
-webkit-animation-iteration-count: infinite;
margin:auto;
margin-top:-125px;
position: static;
}
#-webkit-keyframes rotate {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
#back {
width:auto;
height: 150px;
border: 1px solid red;
-webkit-animation: rotateY linear 5s;
-webkit-animation-iteration-count: infinite;
position: static;
}
#-webkit-keyframes rotateY {
from {
-webkit-transform: rotateY(0deg)
}
to {
-webkit-transform: rotateY(360deg)
}
}
#right_text {
border: 1px solid green;
height: 75px;
width: 75px;
float: right;
margin-top: 35px;
text-align: center;
}
#left_text {
border: 1px solid green;
height: 75px;
width: 75px;
float: left;
margin-top: 35px;
text-align: center;
}
http://jsfiddle.net/bXhL8/
As you can see, both text-divs face their back to the screen when they are not on their side of origin. i want both of them to always stay the same and just "hang on" to the rotation of my back-div.
my question would be if that is possible in css alone or if id need js for it.
Add the following to your css
#left_text, #right_text {
-webkit-animation: rotateY linear 5s;
-webkit-animation-iteration-count: infinite;
}
JSFiddle
Update
Updated JSFiddle
here is my new bit of code. its not a perfect circle yet, because i just added 4 frames to my #keyframes. im thinking about making a actual circular rotation and adding a skew() element to the whole circular function / to my whole body, don't know if that will work though.
thanks for your help!
html:
<div id="right_text">
<div id="right_text_text">TEST</div>
</div>
<div id="left_text">
<div id="left_text_text">TEST2</div>
</div>
<div id="mid"></div>
css:
#mid {
border: 1px solid black;
background-color: red;
height: 100px;
width: 100px;
-webkit-animation: rotate linear 5s;
-webkit-animation-iteration-count: infinite;
margin-top: 105px;
margin-left: 210px;
position: static;
}
#-webkit-keyframes rotate {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(-360deg);
}
}
#right_text_text {
border: 1px solid black;
text-align: center;
position: absolute;
width: 50px;
-webkit-animation: downupright linear 8s infinite;
}
#left_text_text {
border: 1px solid black;
text-align: center;
position: absolute;
width: 50px;
-webkit-animation: updownleft linear 8s infinite;
}
#-webkit-keyframes downupright {
0% { left: 490px; top: 150px;}
25% { left: 245px; top: 100px; z-index: -10;}
50% { left: 0px; top: 150px;}
75% { left: 245px; top: 200px; z-index:10;}
100% { left: 490px; top: 150px;}
}
#-webkit-keyframes updownleft {
0% { left: 0px; top: 150px;}
25% { left: 245px; top: 200px; z-index: 9;}
50% { left: 490px; top: 150px;}
75% { left: 245px; top: 100px; z-index: -9;}
100% { left: 0px; top: 150px;}
}
http://jsfiddle.net/bXhL8/4/