I have a progress element like so:
body {
background: grey;
}
progress[value] {
-webkit-appearance: none;
appearance: none;
height: 25px;
width: 95%;
position: relative;
top: 10px;
right: 50%;
left: 2.5%;
}
progress[value]::-webkit-progress-bar {
background-color: rgba(255,255,255,0.2);
border-radius: 50px;
border: solid;
border-width: 0px;
border-color: rgba(255,255,255,0.1);
}
progress[value]::-webkit-progress-value {
background-image: repeating-linear-gradient(
45deg,
#fff,
#fff 10px,
#f9f9f9 10px,
#f9f9f9 20px
);
border-radius: 50px;
-moz-animation-name: move;
-moz-animation-iteration-count: 1;
-moz-animation-timing-function: ease;
-moz-animation-duration: 0.4s;
-moz-animation-delay: 1.5s;
-moz-animation-fill-mode: forwards;
-webkit-animation-name: move;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: linear;
-webkit-animation-duration: 0.4s;
animation-delay: 1.5s;
animation-name: move;
animation-iteration-count: infinite;
animation-timing-function: linear;
animation-delay: 1.5s;
animation-play-state: running;
}
#keyframes move {
0% {
background-position: 0 0;
}
100% {
background-position: 50px 50px;
}
}
<progress max="100" value="80"></progress>
And I have used CSS animations, however for some reason they do not work. I want the stripes to move horizontally, infinitely. Is there any reason to why this doesn't work?
Note - <progress> is not well supported by IE. See this for a complete guide to make it work across browsers. Below demo is the simplified animation without <progress> element.
body {
background-color: #666;
}
div {
background-color: #999;
border-radius: 30px;
height: 30px;
}
div > div {
background-image: repeating-linear-gradient(-45deg, #fff, #fff 10px, #ccc 10px, #ccc 20px);
background-size: 28px 30px;
animation: progress 2s linear infinite;
width: 50%;
}
#keyframes progress {
0% { background-position: 0 0; }
100% { background-position: 28px 0; }
}
<div><div></div></div>
Related
This loading spinner I have created doesn't show the delay function at the moment I hover on the element, but it rotates a full turn before creating the animation on the second turn; how could I debug this issue?
Kindly, check my codepen code link so you can get what I mean, thank you.
Codepen
Each border of spin pseudo elements must move at different timing from the beginning when I hover on the element, I have set the animation delay function, and it works properly but not at the first turn.
This is how I wrote the code:
.spin {
margin: auto;
margin-top: 23px;
margin-bottom: 23px;
}
.spin div {
width: 50px;
height: 50px;
margin: auto;
border-radius: 50%;
border: 3px solid #2196f3;
border-bottom-color: transparent;
position: relative;
animation-name: spinning;
animation-duration: 1s;
animation-play-state: paused;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.spin div::before {
content: "";
position: absolute;
top: -3px;
right: -3px;
width: 100%;
height: 100%;
border-radius: 50%;
border: 3px solid orange;
border-bottom-color: transparent;
scale: 1.2;
animation-name: spinning;
animation-duration: 2s;
animation-delay: 1s;
animation-iteration-count: infinite;
animation-play-state: paused;
animation-timing-function: linear;
}
.spin div::after {
content: "";
position: absolute;
top: -3px;
right: -3px;
width: 100%;
height: 100%;
border-radius: 50%;
border: 3px solid black;
border-bottom-color: transparent;
scale: 1.4;
animation-name: spinning;
animation-duration: 2s;
animation-delay: 2s;
animation-play-state: paused;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.spin div:hover {
animation-play-state: running;
}
.spin div:hover::before {
animation-play-state: running;
}
.spin div:hover::after {
animation-play-state: running;
}
#keyframes spinning {
100% {
transform: rotate(1turn)
}
}
<div class="spin">
<div></div>
</div>
Commenting out the initial animation-delay: 1s causes the spinners to start immediately out of sync, which I believe is the behavior you are seeking.
.spin {
margin: auto;
margin-top: 23px;
margin-bottom: 23px;
}
.spin div {
width: 50px;
height: 50px;
margin: auto;
border-radius: 50%;
border: 3px solid #2196f3;
border-bottom-color: transparent;
position: relative;
animation-name: spinning;
animation-duration: 1s;
animation-play-state: paused;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.spin div::before {
content: "";
position: absolute;
top: -3px;
right: -3px;
width: 100%;
height: 100%;
border-radius: 50%;
border: 3px solid orange;
border-bottom-color: transparent;
scale: 1.2;
animation-name: spinning;
animation-duration: 2s;
/*animation-delay: 1s;*/
animation-iteration-count: infinite;
animation-play-state: paused;
animation-timing-function: linear;
}
.spin div::after {
content: "";
position: absolute;
top: -3px;
right: -3px;
width: 100%;
height: 100%;
border-radius: 50%;
border: 3px solid black;
border-bottom-color: transparent;
scale: 1.4;
animation-name: spinning;
animation-duration: 2s;
animation-delay: 2s;
animation-play-state: paused;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.spin div:hover {
animation-play-state: running;
}
.spin div:hover::before {
animation-play-state: running;
}
.spin div:hover::after {
animation-play-state: running;
}
#keyframes spinning {
100% {
transform: rotate(1turn)
}
}
<div class="spin">
<div></div>
</div>
As for how to debug it-- there is an "animations drawer" in the Chrome dev tools: you can learn more about the Chrome dev tools animations drawer in this blog post.
Problem is that your first animation spins all 3 of the elements. Your pseudo elements start spinning only after their delay is over. If you want to offset animations from the very beginning you have 2 options.
use negative animation-delay, so for example animation-duration: -2s;
use separate not nested elements for each spinning element.
I want to make like this shape using HTML and CSS:
this is my code but why the before and after elements don't stop rotation when I hover on it:
Code:
body {
height: 100vh;
padding: 0;
margin: 0;
position: relative;
}
#keyframes rotate {
from {
transform: scale(1) rotate(0deg);
}
to {
transform: scale(1) rotate(360deg);
}
}
div {
background-color: #eee;
width: 50px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
color: #000000;
font-size: 30px;
font-weight: bold;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: 10px solid;
border-color: transparent #ea2264 #ea2264 #ea2264;
border-radius: 50%;
animation-name: rotate;
animation-duration: 1s;
animation-delay: 1s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
div::before {
content: "";
position: absolute;
width: 75px;
height: 75px;
border: 10px solid;
border-color: #1790e1 #1790e1 transparent #1790e1;
border-radius: 50%;
animation-name: rotate;
animation-duration: 1s;
animation-delay: 1s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
div::after {
content: "";
position: absolute;
width: 100px;
height: 100px;
border: 10px solid;
border-color: #fca400 #fca400 #fca400 transparent;
border-radius: 50%;
animation-name: rotate;
animation-duration: 1s;
animation-delay: 1s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
div:hover {
animation-play-state: paused;
}
div::after:hover {
animation-play-state: paused;
}
div::before:hover {
animation-play-state: paused;
}
<div></div>
My question is how to animate and pause the rotation of two pseudo elements when I hover on it to make like the design in the picture?
Simply change your selectors from:
div:hover {
animation-play-state: paused;
}
div::after:hover {
animation-play-state: paused;
}
div::before:hover {
animation-play-state: paused;
}
to:
div:hover,
div:hover::after,
div:hover::before {
animation-play-state: paused;
}
your selectors indicate an over on the pseudo-elements. since you only hover the div itself you need to add the ::before/after selector after the :hover selector.
body {
height: 100vh;
padding: 0;
margin: 0;
position: relative;
}
#keyframes rotate {
from {
transform: scale(1) rotate(0deg);
}
to {
transform: scale(1) rotate(360deg);
}
}
div {
background-color: #eee;
width: 50px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
color: #000000;
font-size: 30px;
font-weight: bold;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: 10px solid;
border-color: transparent #ea2264 #ea2264 #ea2264;
border-radius: 50%;
animation-name: rotate;
animation-duration: 1s;
animation-delay: 1s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
div::before {
content: "";
position: absolute;
width: 75px;
height: 75px;
border: 10px solid;
border-color: #1790e1 #1790e1 transparent #1790e1;
border-radius: 50%;
animation-name: rotate;
animation-duration: 1s;
animation-delay: 1s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
div::after {
content: "";
position: absolute;
width: 100px;
height: 100px;
border: 10px solid;
border-color: #fca400 #fca400 #fca400 transparent;
border-radius: 50%;
animation-name: rotate;
animation-duration: 1s;
animation-delay: 1s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
div:hover,
div:hover::after,
div:hover::before {
animation-play-state: paused;
}
<div></div>
I'm using css transition to drawing a line, it run or loading from right to left, and then down, and continue to load to left:
point 1------point 2
|
|
|
---------point 3
this is my css:
.transitionLine {
height:0px;
width:1px;
border:10px solid #ef4e4e;
-webkit-animation: increase 3s;
-moz-animation: increase 3s;
-o-animation: increase 3s;
animation: increase 3s;
animation-fill-mode: forwards;
}
#keyframes increase {
/*load to left*/
30% {
width: 500px;
}
/*load down*/
60% {
border-radius: 3px;
width: 1000px;
}
/*load to left*/
100% {
border-radius: 3px;
width: 1500px;
}
}
<div class="transitionLine"></div>
my css seem not break line to load down and left, how to fix the problem ?
You can achieve this effect as per my snippet.
I have used Two keyframes and an after property to add bottom line
.transitionLine {
height: 0px;
width: 1px;
border-top: 10px solid #ef4e4e;
border-right: 10px solid #ef4e4e;
position: relative;
-webkit-animation: increase 3s;
-moz-animation: increase 3s;
-o-animation: increase 3s;
animation: increase 3s;
animation-fill-mode: forwards;
}
.transitionLine:after {
content: '';
display: block;
height: 0px;
width: 1px;
border-top: 10px solid #ef4e4e;
border-right: 10px solid #ef4e4e;
-webkit-animation: increase2 3s;
-moz-animation: increase2 3s;
-o-animation: increase2 3s;
animation: increase2 3s;
animation-fill-mode: forwards;
position: absolute;
left: 100%;
bottom: 0;
}
#keyframes increase {
/*load to left*/
30% {
width: 200px;
height: 0px;
}
31% {
width: 200px;
height: 1px;
}
/*load down*/
60% {
height: 100px;
width: 200px;
}
/*load to left*/
100% {
height: 100px;
width: 200px;
}
}
#keyframes increase2 {
60% {
height: 0px;
width: 0px;
}
/*load to left*/
100% {
height: 0px;
width: 200px;
}
}
<div class="transitionLine"></div>
You can use gradient to draw lines and you will need only one keyframe:
.transitionLine {
width:300px;
height:100px;
background-image:
linear-gradient(#ef4e4e,#ef4e4e),
linear-gradient(#ef4e4e,#ef4e4e),
linear-gradient(#ef4e4e,#ef4e4e);
background-size:
0% 5px,
5px 0%,
0% 5px;
background-position:
top left,
top center,
150px 100%;
background-repeat:no-repeat;
animation: increase 3s;
animation-fill-mode: forwards;
}
#keyframes increase {
30% {
background-size:
50% 5px,
5px 0%,
0% 5px;
}
/*load down*/
60% {
background-size:
50% 5px,
5px 100%,
0% 5px;
}
/*load to left*/
100% {
background-size:
50% 5px,
5px 100%,
50% 5px;
}
}
<div class="transitionLine"></div>
That you can easily scale to any number of lines:
.transitionLine {
width:300px;
height:100px;
background-image:
linear-gradient(#ef4e4e,#ef4e4e),
linear-gradient(#ef4e4e,#ef4e4e),
linear-gradient(#ef4e4e,#ef4e4e),
linear-gradient(#ef4e4e,#ef4e4e),
linear-gradient(#ef4e4e,#ef4e4e);
background-size:
5px 0%,
0% 5px,
5px 0%,
0% 5px,
5px 0%;
background-position:
bottom left,
top left,
top center,
150px 100%,
right bottom;
background-repeat:no-repeat;
animation: increase 3s;
animation-fill-mode: forwards;
}
#keyframes increase {
20% {
background-size:
5px 100%,
0% 5px,
5px 0%,
0% 5px,
5px 0%;
}
40% {
background-size:
5px 100%,
50% 5px,
5px 0%,
0% 5px,
5px 0%;
}
60% {
background-size:
5px 100%,
50% 5px,
5px 100%,
0% 5px,
5px 0%;
}
80% {
background-size:
5px 100%,
50% 5px,
5px 100%,
50% 5px,
5px 0%;
}
100% {
background-size:
5px 100%,
50% 5px,
5px 100%,
50% 5px,
5px 100%;
}
}
<div class="transitionLine"></div>
.transitionLine {
height:0px;
width:1px;
border:10px solid #ef4e4e;
-webkit-animation: increase 1s;
-moz-animation: increase 1s;
-o-animation: increase 1s;
animation: increase 1s;
animation-fill-mode: forwards;
}
.transitionLine:before{
height: 0px;
content: " ";
width: 0px;
border: 10px solid #ef4e4e;
-webkit-animation: increaseA 1s;
-moz-animation: increaseA 1s;
-o-animation: increaseA 1s;
animation: increaseA 1s;
animation-fill-mode: forwards;
margin: -10px 0 0 510px;
animation-delay: 1s;
display: inline-block;
opacity: 0;
}
.transitionLine:after{
height: 0px;
content: " ";
width: 0px;
border: 10px solid #ef4e4e;
-webkit-animation: increaseB 1s;
-moz-animation: increaseB 1s;
-o-animation: increaseB 1s;
animation: increaseB 1s;
animation-fill-mode: forwards;
margin: 0px 0 0 510px;
animation-delay: 2s;
display: inline-block;
opacity: 0;
}
#keyframes increase {
0% {
width: 0px;
}
100% {
width: 500px;
}
}
#keyframes increaseA {
0% {
height: 0px;
opacity: 1;
}
100% {
height: 500px;
opacity: 1;
}
}
#keyframes increaseB {
0% {
width: 0px;
opacity: 1;
}
100% {
width: 500px;
opacity: 1;
}
}
<div class="transitionLine"></div>
I'm currently developing a website for a group, and I'm trying to animate some dots in the word "Loading..." so they blink. I've got the animation working, but for some reason the dots aren't showing up unless I highlight the text with my cursor.
#keyframes blink {
0% {
opacity: .2;
}
20% {
opacity: 1;
}
100% {
opacity: .2;
}
}
.text span {
animation-name: blink;
animation-duration: 1.4s;
animation-iteration-count: infinite;
animation-fill-mode: both;
}
.text span:nth-child(2) {
animation-delay: .2s;
}
.text span:nth-child(3) {
animation-delay: .4s;
}
.text {
width: 300px;
height: 70px;
font-size: 30px;
background: -webkit-linear-gradient(#ffffff, rgb(183,183,183));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-align: center;
color: white;
}
<div class="text">Loading<span>.</span><span>.</span><span>.</span></div>
The "Loading" part of the text is showing up fine though. Any ideas?
Thanks
You need a color to fall back on for the transparency.
As it stands now, it's already transparent, so the opacity does nothing. If you have a color to go to (not just transparent), it'll show that the relevant percentage, mixed with the gradient. I've done that in the example below using black as the "background".
#keyframes blink {
/* changes the values here */
0% {
-webkit-text-fill-color: rgba(0, 0, 0, 0.2);
}
20% {
-webkit-text-fill-color: rgba(0, 0, 0, 1);
}
100% {
-webkit-text-fill-color: rgba(0, 0, 0, 0.2);
}
}
.text span {
animation-name: blink;
animation-duration: 1.4s;
animation-iteration-count: infinite;
animation-fill-mode: both;
}
.text span:nth-child(2) {
animation-delay: .2s;
}
.text span:nth-child(3) {
animation-delay: .4s;
}
.text {
width: 300px;
height: 70px;
font-size: 30px;
background: -webkit-linear-gradient(#ffffff, rgb(183,183,183));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-align: center;
color: white;
}
<div class="text">Loading<span>.</span><span>.</span><span>.</span></div>
I am trying to make my animation work on firefox, Its working fine on google chrome but not in firefox or any other browser.
Here is the html markup
<div id="blo"></div>
and CSS sheet
#blo {
width: 44px;
height: 43px;
background: url(http://www.noirextreme.com/digital/Earth-Color4096.jpg);border-radius: 50%;
background-size: 86px, 43px;
box-shadow: inset 5px 0 17px 0px rgb(5, 5, 5), inset -2px 1px 3px 1px rgba(255, 255, 255, 0.2);
-webkit-animation-name: rotate;
-webkit-animation-duration: 4s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
-moz-animation-name: rotate;
-moz-animation-duration: 4s;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: linear;
-ms-animation-name: rotate;
-ms-animation-duration: 4s;
-ms-animation-iteration-count: infinite;
-ms-animation-timing-function: linear;
animation-name: rotate;
animation-duration: 4s;
animation-iteration-count: infinite;
animation-timing-function: linear;
z-index: 9999;
position: relative;
#-webkit-keyframes rotate {
from { background-position-x: 0px; }
to { background-position-x: 86px; }
}
#-ms-keyframes rotate {
from { background-position-x: 0px; }
to { background-position-x: 86px; }
}
#-moz-keyframes rotate {
from { background-position-x: 0px; }
to { background-position-x: 86px; }
}
Fiddle: http://jsfiddle.net/J22TN/1/
#keyframes rotate {
from { background-position-x: 0px; }
to { background-position-x: 86px; }
}
change #keyframes to this:
#keyframes rotate {
from { background-position: 0 0; } // changed position-x to position: 0 0
to { background-position: 86px 0; }
}
And also, remove all the -moz- lines. #keyframe animations are directly supported by firefox!
Your Final CSS should be this:
#blo {
width: 44px;
height: 43px;
background: url(http://www.noirextreme.com/digital/Earth-Color4096.jpg);border-radius: 50%;
background-size: 86px, 43px;
box-shadow: inset 5px 0 17px 0px rgb(5, 5, 5), inset -2px 1px 3px 1px rgba(255, 255, 255, 0.2);
-webkit-animation-name: rotate;
-webkit-animation-duration: 4s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
animation-name: rotate;
animation-duration: 4s;
animation-iteration-count: infinite;
animation-timing-function: linear;
z-index: 9999;
position: relative;
}
#-webkit-keyframes rotate {
from { background-position-x: 0px; }
to { background-position-x: 86px; }
}
#keyframes rotate {
from { background-position: 0 0; }
to { background-position: 86px 0; }
}