Css Animation Scale() on Text [duplicate] - css

This question already has answers here:
CSS transform doesn't work on inline elements
(2 answers)
Closed 4 years ago.
I am trying to create a scaling text number to basically pulsate and scale at the same time. I am not sure as to why this isn't working or if I am over riding it some were. The pulsate works fine just not transform.
CSS:
.grad{
color: #0a77d5; /* Old browsers */
color: -moz-linear-gradient(top, #d0e4f7 0%, #73b1e7 24%, #0a77d5 50%, #539fe1 79%, #87bcea 100%); /* FF3.6-15 */
color: -webkit-linear-gradient(top, #d0e4f7 0%,#73b1e7 24%,#0a77d5 50%,#539fe1 79%,#87bcea 100%); /* Chrome10-25,Safari5.1-6 */
color: linear-gradient(to bottom, #d0e4f7 0%,#73b1e7 24%,#0a77d5 50%,#539fe1 79%,#87bcea 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
}
.pulsate {
-webkit-animation: pulsate 1.5s ease-out;
-webkit-animation-iteration-count: infinite;
opacity: 1.0;
}
#-webkit-keyframes pulsate {
0% {
opacity: 0.5;
transform: scale(1.0);
}
50% {
opacity: 1.0;
-webkit-transform: scale(2.0);
}
100% {
opacity: 0.5;
-webkit-transform: scale(3.0);
}
}
**.shadow {
text-shadow: 0 1px 0 #ccc,
0 2px 0 #c9c9c9,
0 3px 0 #bbb,
0 4px 0 #b9b9b9,
0 5px 0 #aaa,
0 6px 1px rgba(0, 0, 0, .1),
0 0 5px rgba(0, 0, 0, .1),
0 1px 3px rgba(0, 0, 0, .3),
0 3px 5px rgba(0, 0, 0, .2),
0 5px 10px rgba(0, 0, 0, .25),
0 10px 10px rgba(0, 0, 0, .2),
0 20px 20px rgba(0, 0, 0, .15);
box-shadow: none !important;
}
HTML:
<b class="shadow grad pulsate">#1</b>

You need to set displayrule, and other changes, like the rules without prefix.
CSS
.grad {
color: #0a77d5;
/* Old browsers */
color: -moz-linear-gradient(top, #d0e4f7 0%, #73b1e7 24%, #0a77d5 50%, #539fe1 79%, #87bcea 100%);
/* FF3.6-15 */
color: -webkit-linear-gradient(top, #d0e4f7 0%, #73b1e7 24%, #0a77d5 50%, #539fe1 79%, #87bcea 100%);
/* Chrome10-25,Safari5.1-6 */
color: linear-gradient(to bottom, #d0e4f7 0%, #73b1e7 24%, #0a77d5 50%, #539fe1 79%, #87bcea 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
}
.pulsate {
-webkit-animation: pulsate 1.5s ease-out;
-webkit-animation-iteration-count: infinite;
animation: pulsate 1.5s ease-out;
animation-iteration-count: infinite;
opacity: 1.0;
transform: scale(1);
display: inline-block; //I set here the display
}
#-webkit-keyframes pulsate {
0% {
opacity: 0.5;
-webkit-transform: scale(1.0);
transform: scale(1.0);
}
50% {
opacity: 1.0;
-webkit-transform: scale(2.0);
transform: scale(2.0);
}
100% {
opacity: 0.5;
-webkit-transform: scale(3.0);
transform: scale(3.0);
}
}
**.shadow {
text-shadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0, 0, 0, .1), 0 0 5px rgba(0, 0, 0, .1), 0 1px 3px rgba(0, 0, 0, .3), 0 3px 5px rgba(0, 0, 0, .2), 0 5px 10px rgba(0, 0, 0, .25), 0 10px 10px rgba(0, 0, 0, .2), 0 20px 20px rgba(0, 0, 0, .15);
box-shadow: none !important;
}
HTML
<b class="shadow grad pulsate">#1</b>
DEMO HERE

Related

How to control shadow of element with CSS?

I am playing around with animating shadow. I want it to work like this: When i click on box, i want class of "shadow" to be added. When it does, i want to animate shadow like it is lifting up, and when removed class, i want shadow to disappear the same way it appears (reverse). I have created keyframes and set the blur and opacity to change.
One thing i notice is, the animation is not smooth, it goes by steps. Why is it so? I want shadow animation to be smooth.
Second, how to create that shadow will also disappear in reverse when class is removed?
Here is my code so far:
const box = document.querySelector(".box");
function shadowHandle(){
box.classList.toggle("shadow");
}
box.addEventListener("click", shadowHandle);
body{
margin: 100px;
}
.box{
width: 100px;
height: 300px;
background-color: red;
}
#-webkit-keyframes shadow { /* Webkit */
0% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
25% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
100% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
}
#-moz-keyframes shadow { /* Webkit */
0% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
25% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
100% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
}
#keyframes shadow { /* Webkit */
0% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
25% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
100% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
}
.shadow {
animation: shadow 2s forwards; /* CSS3 */
-moz-animation: shadow 2s forwards; /* Firefox */
-webkit-animation: shadow 2s forwards; /* Webkit */
}
<div class="box shadow"></div>
I think using a transition is the way to go here. It will animate back "mid-animation".
here's an example with :hover, but you can use an added class as well.
.box{
width: 100px;
height: 100px;
background: silver;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
transition: box-shadow 0.3s ease-in-out;
}
.box:hover {
box-shadow: -4px 0px 40px rgba(0, 0, 0, 1);
}
<div class="box">
</div>
You don't need Keyframes. This is much more easier with transition
const box = document.querySelector(".box");
function shadowHandle(){
box.classList.toggle("shadow");
}
box.addEventListener("click", shadowHandle);
body{
margin: 100px;
}
.box{
width: 100px;
height: 300px;
background-color: red;
box-shadow: none;
transition: all 1s ease;
}
.box.shadow {
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}
<div class="box"></div>
This can be simply achieved through transition
Follow the snippet below:
Add the box-shadow to class shadow
now add CSS transition to the `.box.
transition: all 1s linear
This will animate all css properties which can be animated
For a duration of 1s
In a linear rate. Other values are ease ease-in ease-out, etc
Play around and find out.
const box = document.querySelector(".box");
function shadowHandle() {
box.classList.toggle("shadow");
}
box.addEventListener("click", shadowHandle);
body {
margin: 100px;
}
.box {
width: 100px;
height: 300px;
background-color: red;
transition: all 1s linear;
}
.shadow {
box-shadow: -4px 0px 40px rgba(0, 0, 0, 1);
}
<div class="box"></div>
Added another animation class no-shadow with reverse styles.
#-webkit-keyframes no-shadow { /* Webkit */
0% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
25% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
100% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
}
#-moz-keyframes no-shadow { /* Webkit */
0% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
25% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
100% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
}
#keyframes no-shadow { /* Webkit */
0% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
25% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
100% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
}
.no-shadow {
animation: no-shadow 2s forwards; /* CSS3 */
-moz-animation: no-shadow 2s forwards; /* Firefox */
-webkit-animation: no-shadow 2s forwards; /* Webkit */
}
const box = document.querySelector(".box");
function shadowHandle(){
box.classList.toggle("shadow");
box.classList.toggle("no-shadow");
}
box.addEventListener("click", shadowHandle);
body{
margin: 100px;
}
.box{
width: 100px;
height: 300px;
background-color: red;
}
#-webkit-keyframes shadow { /* Webkit */
0% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
25% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
100% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
}
#-moz-keyframes shadow { /* Webkit */
0% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
25% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
100% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
}
#keyframes shadow { /* Webkit */
0% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
25% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
100% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
}
.shadow {
animation: shadow 2s forwards; /* CSS3 */
-moz-animation: shadow 2s forwards; /* Firefox */
-webkit-animation: shadow 2s forwards; /* Webkit */
}
#-webkit-keyframes no-shadow { /* Webkit */
0% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
25% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
100% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
}
#-moz-keyframes no-shadow { /* Webkit */
0% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
25% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
100% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
}
#keyframes no-shadow { /* Webkit */
0% { box-shadow: -4px 0px 40px rgba(0, 0, 0, 1); }
25% { box-shadow: -3px 0px 30px rgba(0, 0, 0, 0.9); }
50% { box-shadow: -2px 0px 20px rgba(0, 0, 0, 0.7); }
75% { box-shadow: -1px 0px 15px rgba(0, 0, 0, 0.5); }
100% { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); }
}
.no-shadow {
animation: no-shadow 2s forwards; /* CSS3 */
-moz-animation: no-shadow 2s forwards; /* Firefox */
-webkit-animation: no-shadow 2s forwards; /* Webkit */
}
<div class="box shadow"></div>

How to Inherit properties in css?

How to Inherit properties in css? I have a class:
.drop-shadow-red {
font-size: 1.5vh;
padding: 0.4vh 0.7vh;
background: url(../images/redInvert.png) no-repeat center left;
background-position: 8px 50%;
background-size: 2vh;
background-color: rgba(250, 210, 50, 0.9);
font-weight: bold;
-webkit-box-shadow: 0 3px 4px rgba(0, 0, 0, 0.4) , 0 0 40px rgba(0, 0, 0, 0.1) inset;
-mox-box-shadow: 0 3px 4px rgba(0, 0, 0, 0.4) , 0 0 40px rgba(0, 0, 0, 0.1) inset;
box-shadow: 0 3px 4px rgba(0, 0, 0, 0.4) , 0 0 40px rgba(0, 0, 0, 0.15) inset;
-moz-border-radius: 12px 12px 0 0;
border-radius: 0.1vh 0;
height: auto;
max-width: 100%; /* Max Width of the popover (depending on the container!) */
z-index: 99;
animation: blinkBorder .6s step-end infinite alternate;
animation-timing-function: ease-in-out;
animation-delay: 0;
animation-direction: alternate;
animation-iteration-count: infinite;
animation-fill-mode: none;
animation-play-state: running;
}
And I want now to create another class .drop-shadow-yellow that has all properties like .drop-shadow-red but the only change is that background-color is yellow. How to optimize the code to not duplicate so much code, like:
.drop-shadow-yellow {
font-size: 1.5vh;
padding: 0.4vh 0.7vh;
background: url(../images/redInvert.png) no-repeat center left;
background-position: 8px 50%;
background-size: 2vh;
background-color: yellow; /* <-------------------------------------- */
font-weight: bold;
-webkit-box-shadow: 0 3px 4px rgba(0, 0, 0, 0.4) , 0 0 40px rgba(0, 0, 0, 0.1) inset;
-mox-box-shadow: 0 3px 4px rgba(0, 0, 0, 0.4) , 0 0 40px rgba(0, 0, 0, 0.1) inset;
box-shadow: 0 3px 4px rgba(0, 0, 0, 0.4) , 0 0 40px rgba(0, 0, 0, 0.15) inset;
-moz-border-radius: 12px 12px 0 0;
border-radius: 0.1vh 0;
height: auto;
max-width: 100%; /* Max Width of the popover (depending on the container!) */
z-index: 99;
animation: blinkBorder .6s step-end infinite alternate;
animation-timing-function: ease-in-out;
animation-delay: 0;
animation-direction: alternate;
animation-iteration-count: infinite;
animation-fill-mode: none;
animation-play-state: running;
}
Just create a class with all properties but background-color and name it for example drop-shadow.
Now you just create additional classes like red-bg and add background-color: red and pass the drop-shadow class as well as the background class to an object.
Example:
CSS:
.drop-shadow {
font-size: 1.5vh;
padding: 0.4vh 0.7vh;
background: url(../images/redInvert.png) no-repeat center left;
background-position: 8px 50%;
background-size: 2vh;
font-weight: bold;
-webkit-box-shadow: 0 3px 4px rgba(0, 0, 0, 0.4) , 0 0 40px rgba(0, 0, 0, 0.1) inset;
-mox-box-shadow: 0 3px 4px rgba(0, 0, 0, 0.4) , 0 0 40px rgba(0, 0, 0, 0.1) inset;
box-shadow: 0 3px 4px rgba(0, 0, 0, 0.4) , 0 0 40px rgba(0, 0, 0, 0.15) inset;
-moz-border-radius: 12px 12px 0 0;
border-radius: 0.1vh 0;
height: auto;
max-width: 100%; /* Max Width of the popover (depending on the container!) */
z-index: 99;
animation: blinkBorder .6s step-end infinite alternate;
animation-timing-function: ease-in-out;
animation-delay: 0;
animation-direction: alternate;
animation-iteration-count: infinite;
animation-fill-mode: none;
animation-play-state: running;
}
.red-bg{
background-color: rgba(250, 210, 50, 0.9);
}
HTML:
<div class="drop-shadow red-bg">Foo Bar!</div>
If you want to change only one property do it inline style and take everything else from the css.

re-creating a button hover effect from a website

I want to a button with the same hover effect as in foxmovies.com
these are the buttons.
I didn't manage to find an example online, with the arrow moving effect.
any help would be great, thanks.
Created the base hover effect, tweak it for extra efffect
.btn span {
display: inline-block;
font-family: sans-serif;
font-weight: bold;
text-transform: uppercase;
font-size: 14px;
color: #fff;
cursor: pointer;
margin-right: 4px;
height: 48px;
line-height: 48px;
vertical-align: top;
padding: 0 24px;
background-color: #B08A43;
background: -webkit-linear-gradient(right, #B08A43 50%, #CA9E4D 50%);
background: -moz-linear-gradient(right, #B08A43 50%, #CA9E4D 50%);
background: -o-linear-gradient(right, #B08A43 50%, #CA9E4D 50%);
background: linear-gradient(to left, #B08A43 50%, #CA9E4D 50%);
background-size: 200% 100%;
background-position: right bottom;
-webkit-transition: background-position 100ms ease;
-moz-transition: background-position 100ms ease;
transition: background-position 100ms ease;
-moz-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.13);
-webkit-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.13);
box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.13);
}
span.arrow {
background-color: #B08A43;
background: -webkit-linear-gradient(right, #B08A43 50%, #CA9E4D 50%);
background: -moz-linear-gradient(right, #B08A43 50%, #CA9E4D 50%);
background: -o-linear-gradient(right, #B08A43 50%, #CA9E4D 50%);
background: linear-gradient(to left, #B08A43 50%, #CA9E4D 50%);
background-repeat: no-repeat;
background-position: right;
float: none;
line-height: 48px;
background-color: #B08A43;
background-size: 200% 100%;
background-position: right bottom;
-webkit-transition: background-position 200ms ease;
-moz-transition: background-position 200ms ease;
transition: background-position 200ms ease;
-moz-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.13);
-webkit-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.13);
box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.13);
}
a:hover span {
background-position: left bottom;
}
<a class="btn">
<span>Watch the Trailer</span>
<span class="arrow">></span>
</a>

Choppy and Jerky CSS3 animation in Firefox on new "page load"

I am trying to show a CSS3 animation as a loader-animation when I navigate to one of my subpages.
I am using keyframe animation on rotateY.
The issue is that on Firefox, while navigation to another page, the animation does work, but its very jerky and choppy.
While on Chrome and Safari, the same animation works smoothly and perfectly.
Here is a fiddle:
http://jsfiddle.net/p6mgxpbo/
HTML:
<div class="gb-loading">
<div id="animatedElem" class="pin-c">
<div class='pin'></div>
</div>
<div class="pin-mirror"></div>
<div id="gb-lb" class="load-bounce"></div>
</div>
CSS:
.gb-loading {
position: fixed;
left: 0;
right: 0;
top: 50%;
bottom: 0;
width: 70px;
height: 70px;
margin: auto;
z-index: 101;
margin-top: -100px;
}
.pin-c {
width: 70px;
height: 70px;
position: absolute;
top: 0;
left: 0;
z-index: 11;
-webkit-animation: pulsate 1.5s linear infinite;
-moz-animation: pulsate 1.5s linear infinite;
-o-animation: pulsate 1.5s linear infinite;
animation: pulsate 1.5s linear infinite;
}
.pin {
width: 70px;
height: 70px;
background-color: #34baab;
position: absolute;
left: 0;
top: 0;
-webkit-border-radius: 50% 50% 50% 0;
border-radius: 50% 50% 50% 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.pin-mirror {
width: 70px;
height: 70px;
background-color: #003146;
position: absolute;
left: 0;
bottom: -48px;
z-index: -1;
-webkit-border-radius: 50% 0 50% 50%;
border-radius: 50% 0 50% 50%;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.pin:after {
content: '';
width: 25px;
height: 25px;
margin: 22px 0 0 22px;
background-color: #003146;
position: absolute;
-webkit-border-radius: 50%;
border-radius: 50%;
}
.load-bounce {
width: 25px;
height: 25px;
position: absolute;
left: 65px;
background-color: #003146;
-webkit-transform: translateZ(0.5);
-moz-transform: translateZ(0.5);
transform: translateZ(0.5);
-webkit-border-radius: 50%;
border-radius: 50%;
-webkit-animation: bounce .5s linear infinite alternate;
-moz-animation: bounce .5s linear infinite alternate;
-o-animation: bounce .5s linear infinite alternate;
animation: bounce .5s linear infinite alternate;
}
#-webkit-keyframes pulsate {
0% {
-webkit-transform: rotateY(0deg);
}
100% {
-webkit-transform: rotateY(360deg);
}
}
#-moz-keyframes pulsate {
0% {
-moz-transform: rotateY(0deg);
}
100% {
-moz-transform: rotateY(360deg);
}
}
#keyframes pulsate {
0% {
transform: rotateY(0deg);
}
100% {
transform: rotateY(360deg);
}
}
#-webkit-keyframes bounce {
0% {
-webkit-transform: translateY(-10px);
}
100% {
-webkit-transform: translateY(-40px);
}
}
#keyframes bounce {
0% {
transform: translateY(-10px);
}
100% {
transform: translateY(-40px);
}
}
#-moz-keyframes bounce {
0% {
-moz-transform: translateY(-10px);
}
100% {
-moz-transform: translateY(-40px);
}
}
The jerk only comes when Its there on a page which is loading other resources. I am trying to use this element as a pre-loading animation. So it's on the page until the rest of the page is loading. I also have google maps on the same page. So, while the browser is downloading other resources, till that time the animation jerks. You'll not be able to see the jerk on the fiddle.
Need some insights on how to fix this.
Thanks in advance !!
P.S: I did go through a lot of answers related to this on StackOverflow and tried searching on Google, but to no avail.
Sadly, this is something that you will not be able to fix, amend or control with browsers. You will have to use some form of hack to get it to work or confuse the system into doing what you want, but from a normal render, it won't work.
What you could possibly do is add a delay to the animation.
-webkit-animation: pulsate 0.8s linear 10ms infinite;
-moz-animation: pulsate 0.8s linear 10ms infinite;
-o-animation: pulsate 0.8s linear 10ms infinite;
animation: pulsate 0.8s linear 10ms infinite;
JSFiddle Example
What this will do is let the page render, paint and display, then it will wait for 100ms (0.1s) before starting the animation.
If this doesn't work, then it's down to FF not rendering animations as cleanly as Chrome or some other browsers and that is simply a browser issue and will be exceedingly difficult to get round.
Every browser has a completely different tree, render and paint process for displaying HTML & CSS to your monitor. Gecko (FF) and WebKit (Chrome) both use completely different methods and processes to display the page and sadly, when it comes to doing animations, Gecko has the tiniest amount of lag when starting up the animation which is why you see the small bit of lag/jerkiness when the animation begins.
Webkit flow
Gecko flow
As you can see from the above flows, both flows are completely different and the way that the DOM is loaded in, rendered, painted and then displayed is completely different.
Hope this help clears up the issue.
I've added one of the best pieces of information for you to read up on about browser rendering. It's always good to have an understanding of how browsers work when working on the front-end.
How modern browsers work
I am using keyframes with box-shadow to create an animation. Then, I am using the animation command to select the keyframe name and define some detailes on the animation (duration, delay etc...).
#myanimation{
animation: x 1s 1 ease-out ;
-webkit-animation: x 1s 1 ;
-webkit-backface-visibility: hidden;
-moz-animation: x 1s 1;
-o-animation: x 1s 1 ;
}
I will not post my keyframe, because its long. However, even though my animation duration is only 1 seconds, I am experiencing lags.
I tried everything to fix the lags, I added linear,ease-in-out etc.. all kinds of tags to the animation commnad but unsuccessful.
At the end, I just
deactivated the add-ons
(since add-ons also reduce the performance of firefox especially add-ons that block add-ons). After deactivating all my add-ons, it worked perfectly.
For some reason when you animate with Skew(0.1deg) it is not choppy.
This is on firefox 91.0 (64bit).
.test {
animation: breath2 0.8s linear 10ms infinite alternate;
}
#keyframes breath2 {
0% { transform: skewX(0.1deg) scaleX(1) translateY(-10px)}
100% { transform: skewX(0.1deg) scaleX(0.95) translateY(10px)}
}
.button {
border: 1px solid green;
height: 50px;
width: 150px;
border-radius: var(--border-radius);
position: relative;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-transition: all 0.2s ease;
transition: all 0.2s ease;
font: 15px sans-serif;
font-weight: 300;
text-shadow: 0 0 20px #fff;
text-transform: uppercase;
-webkit-animation: breath2 0.8s linear 10ms infinite alternate;
animation: breath2 0.8s linear 10ms infinite alternate;
cursor: pointer;
margin-top: 10px;
text-decoration: none;
}
.button:before {
content: "";
display: block;
width: calc(100% - 10px);
height: calc(50px - 8px);
left: 5px;
top: 3px;
position: absolute;
background-color: transparent;
border: 1px solid #fff;
border-radius: var(--border-radius-before);
}
.button.fire {
border-color: #ffeca8;
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(255, 138, 48, 0.6)), to(rgba(240, 96, 29, 0.6)));
background-image: linear-gradient(to bottom, rgba(255, 138, 48, 0.6), rgba(240, 96, 29, 0.6));
-webkit-box-shadow: 0 0 0px rgba(255, 138, 48, 0.6), 0 0px 3px rgba(240, 96, 29, 0.6), inset 0 1px #ffeca8, inset 0 -1px #ffeca8;
box-shadow: 0 0 0px rgba(255, 138, 48, 0.6), 0 0px 3px rgba(240, 96, 29, 0.6), inset 0 1px #ffeca8, inset 0 -1px #ffeca8;
color: #ffeca8;
}
.button.fire::before {
-webkit-box-shadow: inset 0 0 20px #ffeca8;
box-shadow: inset 0 0 20px #ffeca8;
}
.button.ice {
border-color: #a8ecff;
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(48, 138, 255, 0.6)), to(rgba(29, 96, 240, 0.6)));
background-image: linear-gradient(to bottom, rgba(48, 138, 255, 0.6), rgba(29, 96, 240, 0.6));
-webkit-box-shadow: 0 0 0px rgba(48, 138, 255, 0.6), 0 0px 3px rgba(29, 96, 240, 0.6), inset 0 1px #a8ecff, inset 0 -1px #a8ecff;
box-shadow: 0 0 0px rgba(48, 138, 255, 0.6), 0 0px 3px rgba(29, 96, 240, 0.6), inset 0 1px #a8ecff, inset 0 -1px #a8ecff;
color: #a8ecff;
}
.button.ice::before {
-webkit-box-shadow: inset 0 0 20px #a8ecff;
box-shadow: inset 0 0 20px #a8ecff;
}
.button.blaze {
border-color: #ffa8a8;
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(156, 20, 20, 0.6)), to(rgba(240, 29, 29, 0.6)));
background-image: linear-gradient(to bottom, rgba(156, 20, 20, 0.6), rgba(240, 29, 29, 0.6));
-webkit-box-shadow: 0 0 0px rgba(156, 20, 20, 0.6), 0 0px 3px rgba(240, 29, 29, 0.6), inset 0 1px #ffa8a8, inset 0 -1px #ffa8a8;
box-shadow: 0 0 0px rgba(156, 20, 20, 0.6), 0 0px 3px rgba(240, 29, 29, 0.6), inset 0 1px #ffa8a8, inset 0 -1px #ffa8a8;
color: #ffa8a8;
}
.button.blaze::before {
-webkit-box-shadow: inset 0 0 20px #ffa8a8;
box-shadow: inset 0 0 20px #ffa8a8;
}
.button.nature {
border-color: #b7ffa8;
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(9, 134, 15, 0.6)), to(rgba(36, 240, 29, 0.6)));
background-image: linear-gradient(to bottom, rgba(9, 134, 15, 0.6), rgba(36, 240, 29, 0.6));
-webkit-box-shadow: 0 0 0px rgba(9, 134, 15, 0.6), 0 0px 3px rgba(36, 240, 29, 0.6), inset 0 1px #b7ffa8, inset 0 -1px #b7ffa8;
box-shadow: 0 0 0px rgba(9, 134, 15, 0.6), 0 0px 3px rgba(36, 240, 29, 0.6), inset 0 1px #b7ffa8, inset 0 -1px #b7ffa8;
color: #b7ffa8;
}
.button.nature::before {
-webkit-box-shadow: inset 0 0 20px #b7ffa8;
box-shadow: inset 0 0 20px #b7ffa8;
}
.button:hover {
text-decoration: none;
}
.button:hover.fire {
-webkit-box-shadow: 0 0 10px rgba(255, 138, 48, 0.8), inset 0 1px #ffeca8, inset 0 -1px #ffeca8;
box-shadow: 0 0 10px rgba(255, 138, 48, 0.8), inset 0 1px #ffeca8, inset 0 -1px #ffeca8;
}
.button:hover.fire:before {
-webkit-box-shadow: inset 0 0 50px 0 #ffeca8;
box-shadow: inset 0 0 50px 0 #ffeca8;
}
.button:hover.ice {
-webkit-box-shadow: 0 0 10px rgba(48, 138, 255, 0.8), inset 0 1px #a8ecff, inset 0 -1px #a8ecff;
box-shadow: 0 0 10px rgba(48, 138, 255, 0.8), inset 0 1px #a8ecff, inset 0 -1px #a8ecff;
}
.button:hover.ice:before {
-webkit-box-shadow: inset 0 0 50px 0 #a8ecff;
box-shadow: inset 0 0 50px 0 #a8ecff;
}
.button:hover.blaze {
-webkit-box-shadow: 0 0 10px rgba(156, 20, 20, 0.8), inset 0 1px #ffa8a8, inset 0 -1px #ffa8a8;
box-shadow: 0 0 10px rgba(156, 20, 20, 0.8), inset 0 1px #ffa8a8, inset 0 -1px #ffa8a8;
}
.button:hover.blaze:before {
-webkit-box-shadow: inset 0 0 50px 0 #ffa8a8;
box-shadow: inset 0 0 50px 0 #ffa8a8;
}
.button:hover.nature {
-webkit-box-shadow: 0 0 10px rgba(9, 134, 15, 0.8), inset 0 1px #b7ffa8, inset 0 -1px #b7ffa8;
box-shadow: 0 0 10px rgba(9, 134, 15, 0.8), inset 0 1px #b7ffa8, inset 0 -1px #b7ffa8;
}
.button:hover.nature:before {
-webkit-box-shadow: inset 0 0 50px 0 #b7ffa8;
box-shadow: inset 0 0 50px 0 #b7ffa8;
}
.button:hover + .button:hover {
margin-top: 15px;
-webkit-animation-delay: 0.3s;
animation-delay: 0.3s;
}
.breathingMain {
-webkit-animation: breath2 2s 0.5s infinite alternate;
animation: breath2 2s 0.5s infinite alternate;
}
#-webkit-keyframes breath {
0% {
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
100% {
-webkit-transform: scaleX(0.95);
transform: scaleX(0.95);
}
}
#keyframes breath {
0% {
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
100% {
-webkit-transform: scaleX(0.95);
transform: scaleX(0.95);
}
}
.test {
-webkit-animation: breath2 0.8s linear 10ms infinite alternate;
animation: breath2 0.8s linear 10ms infinite alternate;
}
#-webkit-keyframes breath2 {
0% {
-webkit-transform: skewX(0.1deg) scaleX(1) translateY(-10px);
transform: skewX(0.1deg) scaleX(1) translateY(-10px);
}
100% {
-webkit-transform: skewX(0.1deg) scaleX(0.95) translateY(10px);
transform: skewX(0.1deg) scaleX(0.95) translateY(10px);
}
}
#keyframes breath2 {
0% {
-webkit-transform: skewX(0.1deg) scaleX(1) translateY(-10px);
transform: skewX(0.1deg) scaleX(1) translateY(-10px);
}
100% {
-webkit-transform: skewX(0.1deg) scaleX(0.95) translateY(10px);
transform: skewX(0.1deg) scaleX(0.95) translateY(10px);
}
}
#-webkit-keyframes breath2_orig {
0% {
-webkit-transform: skewX(-10deg) scaleX(1);
transform: skewX(-10deg) scaleX(1);
}
100% {
-webkit-transform: skewX(-10deg) scaleX(0.95);
transform: skewX(-10deg) scaleX(0.95);
}
}
#keyframes breath2_orig {
0% {
-webkit-transform: skewX(-10deg) scaleX(1);
transform: skewX(-10deg) scaleX(1);
}
100% {
-webkit-transform: skewX(-10deg) scaleX(0.95);
transform: skewX(-10deg) scaleX(0.95);
}
}
/*# sourceMappingURL=buttons.css.map */
<div class="container">
<button class="button ice">Button</button>
</div>
Sorry for the long snippet (my first contribution :) )

CSS3 multiple box-shadow transition in Firefox not working

This transition works in Safari & Chrome (= Webkit browsers), but not in Firefox (= Mozilla). Why?
a.lorem {
width: 100px;
padding: 20px;
display: block;
color: white;
text-align: center;
background: rgb(191,210,85);
background: -moz-linear-gradient(top, rgb(191,210,85) 0%, rgb(142,185,42) 50%, rgb(114,170,0) 51%, rgb(158,203,45) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgb(191,210,85)), color-stop(50%,rgb(142,185,42)), color-stop(51%,rgb(114,170,0)), color-stop(100%,rgb(158,203,45)));
background: -webkit-linear-gradient(top, rgb(191,210,85) 0%,rgb(142,185,42) 50%,rgb(114,170,0) 51%,rgb(158,203,45) 100%);
background: -o-linear-gradient(top, rgb(191,210,85) 0%,rgb(142,185,42) 50%,rgb(114,170,0) 51%,rgb(158,203,45) 100%);
background: -ms-linear-gradient(top, rgb(191,210,85) 0%,rgb(142,185,42) 50%,rgb(114,170,0) 51%,rgb(158,203,45) 100%);
background: linear-gradient(to bottom, rgb(191,210,85) 0%,rgb(142,185,42) 50%,rgb(114,170,0) 51%,rgb(158,203,45) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bfd255', endColorstr='#9ecb2d',GradientType=0 );
box-shadow: inset 0 -3px 0 #A9A9A9,
0 3px 0 #EFEFED;
-webkit-transition: box-shadow .5s linear;
-moz-transition: box-shadow .5s linear;
-o-transition: box-shadow .5s linear;
-ms-transition: box-shadow .5s linear;
transition: box-shadow .5s linear;
}
a:hover.lorem {
box-shadow: 0 3px 0 rgba(0, 0, 0, .1),
inset 0 -3px 0 rgba(0, 0, 0, .1),
inset 0 0 100px rgba(255, 255,255 , .3);
}
Fiddle
​
first, you need to write a.lorem:hover and not a:hover.lorem
after, border-shadow multi values need to be corresponding to their ":hover" pair.
"inset" border-shadow can't transit to "outset" border-shadow.
exemple :
a.lorem{
box-shadow:
inset 0 -3px 0 #A9A9A9,
0 3px 0 #EFEFED,
inset 0 0 0 rgba(0,0,0,0); /* for third ":hover" value */
transition:box-shadow .5s linear; /* add prefixed verison (-moz-, -webkit-, ...*/
}
a.lorem:hover{
box-shadow:
inset 0 -3px 0 rgba(0, 0, 0, .1),
0 3px 0 rgba(0, 0, 0, .1),
inset 0 0 100px rgba(255, 255,255 , .3);
}

Resources