I've found this video from the Google style guide
http://material-design.storage.googleapis.com/videos/components-progressandactivity-progressandactivity-_20spec.linear_large_xhdpi.mp4
at this page
http://www.google.com/design/spec/components/progress-activity.html#progress-activity-types-of-indicators
I like the way the progress is shown. Does anybody know, if there is an implementation with CSS3 around? I tried it myself, but this is the closest I've come so far for the second progress bar:
http://plnkr.co/edit/v4jcJlpusKqEK3AySOBZ?p=preview
<div class="spinner">
<div class="bar bar1"></div>
<div class="bar bar2"></div>
</div>
And here is the CSS as SCSS:
#mixin keyframes($name) {
#-webkit-keyframes #{$name} {
#content;
}
#-moz-keyframes #{$name} {
#content;
}
#-ms-keyframes #{$name} {
#content;
}
#keyframes #{$name} {
#content;
}
}
#mixin animation($animation) {
-webkit-animation: #{$animation};
-moz-animation: #{$animation};
-ms-animation: #{$animation};
animation: #{$animation};
}
$spinner-height: 7px;
$green: #8bc34a;
.spinner {
position: relative;
width: 100%;
height: $spinner-height;
opacity: 1;
background-color: lighten($green, 25%);
overflow: hidden;
.bar {
height: $spinner-height;
background-color: $green;
position: absolute;
}
.bar1 {
left: 50%;
width: 10%;
#include animation(bar1 7s infinite linear);
}
.bar2 {
left: 0%;
width: 0%;
#include animation(bar2 7s infinite);
}
}
#include keyframes(bar1) {
0% { width: 0%; left: 0%; }
10% { width: 30%; left: 100%; }
19.99% { width: 30%; left: 100%; }
20% { width: 0%; left: 0%; }
30% { width: 80%; left: 100%; }
30.01% { width: 0%; left: 0%; }
40% { width: 5%; left: 30%; }
50% { width: 50%; left: 100%; }
50.01% { width: 0%; left: 0%; }
60% { width: 60%; left: 20%; }
70% { width: 5%; left: 100%; }
70.01% { width: 0%; left: 0%; }
80% { width: 50%; left: 30%; }
90% { width: 10%; left: 80%; }
100% { width: 20%; left: 100%; }
}
#include keyframes(bar2) {
0% { width: 0%; left: 0%; }
10% { width: 60%; }
19.99% { width: 40%; left: 100%; }
20% { width: 0%; left: 0%; }
25% { width: 10%; left: 10%; }
30% { width: 40%; left: 30%; }
40% { width: 60%; left: 100%; }
40.01% { width: 0%; left: 0%; }
50% { width: 10%; left: 40%; }
60% { width: 30%; left: 100%; }
60.01% { width: 0%; left: 0%; }
70% { width: 10%; left: 40%; }
80% { width: 5%; left: 100%; }
80.01% { width: 0%; left: 0%; }
90% { width: 70%; left: 10%; }
100% { width: 10%; left: 100%; }
}
Maybe someone can help me to come closer to this animation.
With one div class .loading, here's a possible answer to the second one (you'll need to prefix the animations / transitions)
.loading{
width:90%;
margin:0 auto;
height:8px;
background-color:lightblue;
position:relative;
transition: all 300ms ease-in-out;
}
.loading:hover{
height:20px;
}
.loading:before, .loading:after{
content:"";
display:block;
height:100%;
position:absolute;
background-color:blue;
animation:motion 2s infinite ease;
border-radius:3px;
}
.loading:after{
animation-delay:600ms;
}
#keyframes motion{
0% {left:0; width:0;}
20% {left:20%; width:60%;}
40% {left:30%; width:20%;}
60% {left:60%; width:10%;}
80% {left:70%; width:30%;}
100% {left:100%; width:0;}
}
I added the height transition on hover (which is probably what would occur on an event listener instead starting at height:0;).
Related
Please help, when I'm trying to play animation with moving ball in position X and Y at the same time it doesn't work, some strange behaviour. I would like to look like a batted and falling ball
.ball {
position: absolute;
left: 18%;
bottom: 100px;
width: 40px;
height: 40px;
background-color: cadetblue;
border-radius: 50%;
animation: fly-ball-x 2s, fly-ball-y 2s;
}
#keyframes fly-ball-x {
100% {
transform: translateX(300px);
}
}
#keyframes fly-ball-y {
100% {
transform: translateY(100px);
}
}
<div class="ball"></div>
**The result I'm expecting is like the code below:**
#keyframes fly-ball-x {
100% {
left: 300px;
}
}
#keyframes fly-ball-y {
100% {
bottom: 0;
}
}
.ball {
position: absolute;
left: 18%;
bottom: 100px;
width: 40px;
height: 40px;
background-color: cadetblue;
border-radius: 50%;
animation: fly-ball-x 2s cubic-bezier(0.17, 0.67, 0.6, 1), fly-
ball-y 2s;
}
<div class="ball"></div>
.ball {
position: absolute;
left: 18%;
bottom: 100px;
width: 40px;
height: 40px;
background-color: cadetblue;
border-radius: 50%;
animation: fly-ball 2s
}
#keyframes fly-ball {
100% {
transform: translateX(300px) translateY(100px);
}
}
<div class="ball"></div>
It is because you weren't running the animations concurrently. Here both translations are just being run at the same time. You just had a bit more than you needed.
EDIT
Check out this blog post. It gives explanations on the kinds of curves it seems you are going for Curved Path Animations In CSS
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>
Inspired by this tutorial http://tympanus.net/codrops/2014/01/07/shape-hover-effect-with-svg/ I decided to make pure css version of similar effect.
And it looks good and work pretty smooth. What bothers me is why after few attempts I had to set keyframes at 24% and 74% instead of 50%? With 50% animation looks choppy. I really don't like to do things blindfolded, so I'll be grateful for help.
Here is quick dirty implementation:
html {
background: #ccc;
}
.card {
position: relative;
display: inline-block;
height: 400px;
width: 200px;
background: #000;
margin: 50px;
overflow: hidden;
}
.card-head {
position: absolute;
background: #000;
height: 400px;
width: 400px;
border-radius: 50%;
left: -100px;
top: -173px;
z-index: 10;
-webkit-animation-name: carda;
animation-name: carda;
}
.card-extend {
position: absolute;
background: #fff;
height: 400px;
width: 400px;
bottom: -200px;
left: -100px;
z-index: 5;
-webkit-animation-name: cardb;
animation-name: cardb;
}
.card-animated {
-webkit-animation-duration: .2s;
animation-duration: .2s;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
-webkit-animation-timing-function:ease-in-out;
animation-timing-function:ease-in-out;
}
.card:hover .card-head,
.card:focus .card-head{
-webkit-animation-name: cardhovera;
animation-name: cardhovera;
}
.card:hover .card-extend,
.card:focus .card-extend{
-webkit-animation-name: cardhoverb;
animation-name: cardhoverb;
}
#-webkit-keyframes carda {
from {
border-radius: 0%;
top: -320px;
z-index: 2;
}
24% {
top: -320px;
border-radius: 25%;
z-index: 2;
}
to {
border-radius: 50%;
top: -173px;
}
}
#keyframes carda {
from {
border-radius: 0%;
top: -320px;
z-index: 2;
}
24% {
top: -320px;
border-radius: 25%;
z-index: 2;
}
to {
border-radius: 50%;
top: -173px;
}
}
#-webkit-keyframes cardhovera {
from {
border-radius: 50%;
top: -173px;
}
76% {
top: -320px;
border-radius: 25%;
z-index: 2;
}
to {
border-radius: 0%;
top: -320px;
z-index: 2;
}
}
#keyframes cardhovera {
from {
border-radius: 50%;
top: -173px;
}
76% {
top: -320px;
border-radius: 25%;
z-index: 2;
}
to {
border-radius: 0%;
top: -320px;
z-index: 2;
}
}
#-webkit-keyframes cardb {
from {
bottom: -53px;
border-radius: 50%;
}
76% {
bottom: -200px;
border-radius: 25%;
}
to {
border-radius: 0;
z-index: 5;
bottom: -200px;
}
}
#keyframes cardb {
from {
bottom: -53px;
border-radius: 50%;
}
76% {
bottom: -200px;
border-radius: 25%;
}
to {
border-radius: 0;
z-index: 5;
bottom: -200px;
}
}
#-webkit-keyframes cardhoverb {
from {
border-radius: 0;
z-index: 5;
bottom: -200px;
}
24% {
bottom: -200px;
border-radius: 25%;
}
to {
bottom: -53px;
border-radius: 50%;
}
}
#keyframes cardhoverb {
from {
border-radius: 0;
z-index: 5;
bottom: -200px;
}
24% {
bottom: -200px;
border-radius: 25%;
}
to {
bottom: -53px;
border-radius: 50%;
}
}
<div tabindex="0" class="card">
<div class="card-head card-animated">
</div>
<div class="card-extend card-animated">
</div>
</div>
I think this choppy effect you are talking about has more to do with the way animation in css work. As the easing is applied to the whole extension of it, this means, imagine some keyframes like this:
#keyframes exampleFrames {
0% {
transform: translateX(50px)
}
50% {
transform: translateX(0)
}
100% {
transform: translateX(50px)
}
}
Even though you can add easing to the animation the element affected will start at 50 pixels to the right and start moving to the left to it's initial position and in the center frame will suddenly change direction to get to the last position again. The issue is with this sudden change, this is what makes it choppy.
To avoid this you might need to use javascript or, as you've seen tweak the keyframes to minimise this undesirable visual effect.
I want to do this: -webkit-transform: translateX(300px) but from the right instead of having the origin on left.
I tried -webkit-transform-origin: 100% 100% and even top right and it didn't affect it.
Is there a way to do it?
By the power of CSS:
body {
padding: 0;
margin: 0;
}
#page {
position: absolute;
width: 100%;
height: 100%;
background-color: black;
z-index:2;
right:0;
}
#left_drawer {
background-color: #222222;
position: absolute;
top: 0;
right: 0;
width: 300px;
height: 100%;
z-index: 1;
}
#toggle {
width: 50px;
height: 50px;
background-color: red;
float: right;
}
.open_drawer {
-webkit-animation: open_drawer 300ms ease-in-out;
-webkit-animation-fill-mode: forwards;
-webkit-transform: translateX(0);
}
#-webkit-keyframes open_drawer {
to {
-webkit-transform: translateX(-300px);
}
}
This will make it slide in from the right. Fiddle.
I have an accordion slider. which is using CSS3 is their a way to make the slider auto rotate with out using jquery but only with pure css3 animations?
Here is the URL to my site.
Like this?
http://jsfiddle.net/coma/bXDHE/30/
HTML
<div class="neat">
<div>
<img src="http://www.menucool.com/slider/prod/image-slider-4.jpg"/>
<img src="http://blogs.mathworks.com/pick/files/zebrainpastelfield.png"/>
<img src="http://www.freewarepocketpc.net/wp7/img/image-effecter-free.png"/>
<img src="http://www.poyraz.gen.tr/wp-content/uploads/images_4781_1.jpg"/>
</div>
</div>
CSS
div.neat {
font-size: 500px;
width: 1em;
height: 200px;
overflow: hidden;
}
div.neat > div {
position: relative;
left: 0;
width: 4em;
-webkit-animation: loop 10s infinite;
-moz-animation: loop 10s infinite;
}
div.neat > div > img {
width: 1em;
display: block;
float: left;
}
#-webkit-keyframes loop {
0% { left: 0; }
20% { left: 0; }
25% { left: -1em; }
45% { left: -1em; }
50% { left: -2em; }
70% { left: -2em; }
75% { left: -3em; }
95% { left: -3em; }
}
#-moz-keyframes loop {
0% { left: 0; }
20% { left: 0; }
25% { left: -1em; }
45% { left: -1em; }
50% { left: -2em; }
70% { left: -2em; }
75% { left: -3em; }
95% { left: -3em; }
}