css3 animation not working well on Firefox - css

I am trying to upload the three blocks one by one and I want to make animation control the transform with the help of CSS3. Now what's happening is, it's working fine in google chrome (exactly the way I want) but it's not working fine in firefox. In firefox the three blocks are coming visible first and than the css3 animation starts working, which I don't want. I want the animation from the starting as its coming in google chrome.
body {
font-size: 14px;
line-height: 18px;
font-family: arial;
}
.wrapper {
width: 960px;
margin: 10px auto;
}
.one {
float: left;
width: 100px;
height: 100px;
margin: 20px 0;
border: 1px solid #afafaf;
background: #ddd;
animation: one 1s ease 1s;
-webkit-animation: one 1s ease 1s;
}
#keyframes one {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
#-webkit-keyframes one {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
.two {
float: left;
width: 100px;
height: 100px;
margin: 20px 0;
border: 1px solid #afafaf;
background: #ddd;
animation: two 2s ease 2s;
-webkit-animation: two 2s ease 2s;
}
#keyframes two {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
#-webkit-keyframes two {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
.three {
float: left;
width: 100px;
height: 100px;
margin: 20px 0;
border: 1px solid #afafaf;
background: #ddd;
animation: two 3s ease 3s;
-webkit-animation: two 3s ease 3s;
}
#keyframes three {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
#-webkit-keyframes three {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
<section class="wrapper">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</section>

There are several things you should change.
The first is that you should use a common class for all three since they're styled similarly and all having the same effect. I used a class called fadein (and also renamed the animation to this, though they don't need to match).
The second is that you can reuse the same animation for each, just use different animation-delays so that they're spaced out differently.
The third is that you need to have the initial state of all of them be scale(0) so that they don't show in FF. You can then use animation-direction:forwards to make sure they show after the animation as well.
Lastly, if you're going to use -webkit-keyframes, you should use -webkit-transform inside of that as well so that you get more browser support.
body {
font-size: 14px;
line-height: 18px;
font-family: arial;
}
.wrapper {
width: 960px;
margin: 10px auto;
}
.fadein {
float: left;
width: 100px;
height: 100px;
margin: 20px 0;
border: 1px solid #afafaf;
background: #ddd;
transform:scale(0);
-webkit-transform:scale(0);
animation: fadein 1s ease 1s forwards;
-webkit-animation: fadein 1s ease 1s forwards;
}
#keyframes fadein {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
#-webkit-keyframes fadein {
0% {
-webkit-transform: scale(0);
}
100% {
-webkit-transform: scale(1);
}
}
.two {
animation-delay: 2s;
-webkit-animation-delay: 2s;
}
.three {
animation-delay: 3s;
-webkit-animation-delay: 3s;
}
<section class="wrapper">
<div class="fadein one"></div>
<div class="fadein two"></div>
<div class="fadein three"></div>
</section>

Related

Delete empty space between <h2> and CSS animation

In the following snippet you can see a space between h2 and animation. I want it remove it in my case.How can I do this?
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 50px;
height: 50px;
-webkit-animation: spin 2s linear infinite;
/* Safari */
animation: spin 2s linear infinite;
}
/* Safari */
#-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
h2 {
text-align: center;
}
<h2>xyzxyzxyzxyz.
<div class="loader" style="float:right;"></div>
</h2>
JSFIDDLE: https://jsfiddle.net/wdzLv7tk/
Float:right cause the problem. There are so many ways to keep the element side by side. I applied one of them. Here I have display:table for my parent element and for each child it is display:table-cell which gives a solution to your problem.
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 50px;
height: 50px;
-webkit-animation: spin 2s linear infinite;
/* Safari */
animation: spin 2s linear infinite;
}
.parent {
display: table;
margin:auto;
}
.child {
display: table-cell;
}
h2 {}
/* Safari */
#-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
h2 {
text-align: center;
}
<div class="parent">
<h2 class="child">xyzxyzxyzxyz.</h2>
<div class="loader child" style=""></div>
</div>
Just use text-align: right instead of text-align: center
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 50px;
height: 50px;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}
/* Safari */
#-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
#keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
h2 {
text-align: right;
}
<h2>xyzxyzxyzxyz.<div class="loader" style="float:right;"></div></h2>

Customize css loader in angular

I have this loader working fine.
CSS:
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}
/* Safari */
#-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
#keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
<div *ngIf="somevalue" class="loader"></div>
Now I need put some text in center
but my try not working. How Can I let my loader like in second image? I dont want install more external components, md-progress-loader, md-circle...etc.. TRY IT
A very simple solution is to just place the text into another div and position it accordingly - something like
<div class="container">
<div class="loader"></div>
<div class="description">Text</div>
</div>
and
.description
{
position: absolute;
top:0;
left:0;
line-height:150px;
width:152px;
text-align:center;
}
.container
{
position:relative;
}
This counters the rotation and provides a roughly sane box in which other elements can be placed.
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
}
#keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loader div {
display: block;
animation: spin 2s linear infinite reverse;
position: relative;
height: 100%;
}
.loader div span {
display: inline-block;
text-align: center;
}
<div *ngIf="somevalue" class="loader"><div><span>testing lots of text in this text box</span></div></div>

CSS3 keyframe jumps to end of animation without animating

In the linked fiddle, an element has two animations.
https://jsfiddle.net/ccqpLa6L/1/
Below is a capture of the CSS:
#-webkit-keyframes slideInLeft { 0% { transform: translateX(-200px); } 100% { transform: translateX(0); } }
#-webkit-keyframes slideOutLeft { 0% { transform: translateX(0); } 100% { transform: translateX(100px); }}
.element {
width: 250px;
height: 75px;
background-color: dimgrey;
right: 0;
margin-bottom: 10px;
border-radius: 5px;
-webkit-animation: slideInLeft 1s forwards, slideOutLeft 2s forwards;
-webkit-animation-delay: 0s, 1s;
}
The first animation executes without an issue, but the second animation jumps to the end of its animation without any interstitial frames.
Why?
While I'm not exactly sure why the animation wasn't running properly, I was able to achieve the desired effect using spaced out percentages in one keyframe:
https://jsfiddle.net/ccqpLa6L/5/
#-webkit-keyframes slideInLeft {
0% {
transform: translateX(-200px);
}
25% {
transform: translateX(0);
}
50% {
transform: translateX(0);
}
100% {
-webkit-transform: translateX(100px);
}
}
.element {
width: 250px;
height: 75px;
background-color: dimgrey;
margin-bottom: 10px;
border-radius: 5px;
-webkit-animation: slideInLeft 4s forwards;
}

CSS: Loading spinner squared circle look

I am trying to implement a spinner only using CSS that looks like on following image, see the picture. Only one piece of the spinner is filled with color at a time.
In the following fiddle, there is a similar spinner, but I need to rotate the whole spinner (22.5°) and also to modify its rays.
http://jsfiddle.net/ucsnaukf/
HTML:
<div class="spinner"><div>Loading…</div></div>
CSS:
#-webkit-keyframes spin {
to { transform: rotate(1turn); }
}
#-moz-keyframes spin {
to { transform: rotate(1turn); }
}
#-ms-keyframes spin {
to { transform: rotate(1turn); }
}
#keyframes spin {
to { transform: rotate(1turn); }
}
.spinner {
position: relative;
display: inline-block;
width: 5em;
height: 5em;
margin: 0 .5em;
font-size: 12px;
text-indent: 999em;
overflow: hidden;
-webkit-animation: spin 0.8s infinite steps(8);
-moz-animation: spin 0.8s infinite steps(8);
-ms-animation: spin 0.8s infinite steps(8);
-o-animation: spin 0.8s infinite steps(8);
animation: spin 0.8s infinite steps(8);
}
.spinner:before,
.spinner:after,
.spinner > div:before,
.spinner > div:after {
content: '';
position: absolute;
top: 0;
left: 2.25em; /* (container width - part width)/2 */
width: .5em;
height: 1.5em;
border-radius: .2em;
background: #eee;
box-shadow: 0 3.5em #eee; /* container height - part height */
transform-origin: 50% 2.5em; /* container height / 2 */
}
.spinner:before {
background: blue;
}
.spinner:after {
transform: rotate(-45deg);
}
.spinner > div:before {
transform: rotate(-90deg);
}
.spinner > div:after {
transform: rotate(-135deg);
}
Can anyone help?
Here's a start for you (http://jsfiddle.net/ucsnaukf/73/):
<--! HTML -->
<div class="wrapper">
<div class="spinner">
<div>Loading…
</div>
</div>
<div class="circ"></div>
</div>
/* CSS */
#-webkit-keyframes spin {
to { transform: rotate(1turn); }
}
#-moz-keyframes spin {
to { transform: rotate(1turn); }
}
#-ms-keyframes spin {
to { transform: rotate(1turn); }
}
#keyframes spin {
to { transform: rotate(1turn); }
}
.wrapper{
border:1px solid white;
border-radius:100%;
position:relative;
width: 5em;
height: 5em;
border-radius:999px;
overflow:hidden;
}
/* Circular mask */
.circ{
border:1px solid WHITE;
position:absolute;
top:10%;
left:10%;
right:0;
bottom:0;
width:55%;
height:55%;
background-color:#fff;
border-radius:999px;
}
.spinner {
border:1px solid white;
border-radius:100%;/* Round the border */
position: absolute;
display: inline-block;
width: 5em;
height: 5em;
font-size: 12px;
text-indent: 999em;
overflow: hidden;
-webkit-animation: spin 0.8s infinite steps(8);
-moz-animation: spin 0.8s infinite steps(8);
-ms-animation: spin 0.8s infinite steps(8);
-o-animation: spin 0.8s infinite steps(8);
animation: spin 0.8s infinite steps(8);
}
.spinner:before,
.spinner:after,
.spinner > div:before,
.spinner > div:after {
content: '';
position: absolute;
top: 0;
left: 1.8em; /* (container width - part width)/2 */
width: 1.4em; /* longer */
height: .8em; /* shorter */
background: #eee;
box-shadow: 0 4.2em #eee; /* container height - part height */
transform-origin: 50% 2.5em; /* container height / 2 */
}
.spinner:before {
background: purple;
}
.spinner:after {
transform: rotate(-45deg);
}
.spinner > div:before {
transform: rotate(-90deg);
}
.spinner > div:after {
transform: rotate(-135deg);
}
Looks a bit flower like, but continue playing with it and you'll get it the way you want.
You may want to consider used one of the many, great looking, free to use spinners available on the web... check out this massive collection for example: http://codepen.io/collection/HtAne/

Css animation across an Arc [duplicate]

This question already has answers here:
CSS3 Translate across an Arc
(3 answers)
Closed 7 years ago.
Is it possible with current CSS3 to animate an object (DIV) along an this arc?
I've forked the (very good) #ArunBertil "fulcrum" solution to convert it to CSS3 Animation:
Running Demo
CSS
#keyframes drawArc1 {
0% { transform: rotate(180deg); }
100% { transform: rotate(0deg); }
}
#keyframes drawArc2 {
0% { transform: rotate(-180deg); }
100% { transform: rotate(0deg); }
}
body{
padding: 150px;
background: black;
}
.wrapper {
width: 300px;
animation: drawArc1 3s linear infinite;
}
.inner {
border-radius: 50%;
display: inline-block;
padding: 30px;
background: yellowgreen;
animation: drawArc2 3s linear infinite;
}
HTML
<div class="wrapper">
<div class="inner"></div>
</div>
Watch it on FireFox... to run it on other browsers, simply put the prefixes (#-webkit-keyframes, etc)
Check this
http://dabblet.com/gist/1615901
.wrapper {
width: 500px;
margin: 300px 0 0;
transition: all 1s;
transform-origin: 50% 50%;
}
.inner {
display: inline-block;
padding: 1em;
transition: transform 1s;
background: lime;
}
html:hover .wrapper {
transform: rotate(180deg);
}
html:hover .inner {
transform: rotate(-180deg);
}
Well, working on the work of Andrea based on the work of Arun ...
simplified to make use of only 1 div, and 1 animation:
#keyframes drawArc {
0% { transform: rotate(0deg) translateX(150px) rotate(0deg) ;}
100%{ transform: rotate(-180deg) translateX(150px) rotate(180deg); }
}
#-webkit-keyframes drawArc {
0% { -webkit-transform: rotate(0deg) translateX(150px) rotate(0deg) ;}
100%{ -webkit-transform: rotate(-180deg) translateX(150px) rotate(180deg); }
}
body{
padding: 150px;
background: black;
}
.test {
width: 30px;
border-radius: 50%;
display: inline-block;
padding: 30px;
background: yellowgreen;
animation: drawArc 3s linear infinite;
-webkit-animation: drawArc 3s linear infinite;
}
demo
Added also text in the div to show that it doesn't rotate

Resources