CSS3 border animation ghost - css

I have this little border animation but has a ghost in the left top corner, a black dot, I don't know how to get rid of it... You can check it here: http://codepen.io/xaeoc/pen/xGRgze
body {
background-color: #333;
height: 230px;
}
.lluv {
width: 230px;
height: 230px;
border: solid red 1px;
position: absolute;
left: calc(50% - 115px);
}
.ondas1 {
border-radius: 50%;
border-width: 3px;
border-style: solid;
position: absolute;
animation: ondas1 1s ease-out;
}
#keyframes ondas1 {
0% {
width: 0px;
height: 0px;
top: calc(50% - 0px);
left: calc(50% - 0px);
border-color: rgba(255, 255, 255, .7);
}
100% {
width: 200px;
height: 200px;
top: calc(50% - 100px);
left: calc(50% - 100px);
border-color: rgba(255, 255, 255, 0);
}
}

use forwards should be animation: ondas1 1s ease-out forwards;
demo - http://codepen.io/victorfdes/pen/EjNWNY
more explanation about animation-fill-mode
after the animation is complete it goes to default state which has border 3px thats the reason you are seeing the rounded element at the left top once you use forwards the animation doesnt go the the default stated instead it goes to the last state in the keyframe

It's due to the border in ondas1. This should remedy your issue.
Sample
CSS
body {
background-color: #333;
height: 230px;
}
.lluv {
width: 230px;
height: 230px;
border: solid red 1px;
position: relative;
overflow: hidden;
left: calc(50% - 115px);
}
.ondas1 {
border-radius: 50%;
border-width: 3px;
border-style: solid;
left:-10px;
position: absolute;
animation: ondas1 1s ease-out;
}
#keyframes ondas1 {
0% {
width: 0px;
height: 0px;
top: calc(50% - 0px);
left: calc(50% - 0px);
border-color: rgba(255, 255, 255, .7);
}
100% {
width: 200px;
height: 200px;
top: calc(50% - 100px);
left: calc(50% - 100px);
border-color: rgba(255, 255, 255, 0);
}
}

Related

how to animate a variable change in css keyframes

I want to animate the waves to go up when i click on the div i cant get the wave to animate when i change the heigt on the animation it self.
.tsx
<div className={styles.circle}>
<div className={styles.wave}></div>
</div>
.css
.circle {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-190%, -50%);
width: 25%;
height: 60%;
background: #ccc;
box-shadow: 0 0 0 5px #fff;
border-radius: 50%;
overflow: hidden;
}
.wave {
position: relative;
width: 100%;
height: 100%;
background: #4973ff;
border-radius: 50%;
box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
}
.wave:before,
.wave:after {
content: "";
position: absolute;
width: 200%;
height: 200%;
top: 0;
left: 50%;
transform: translate(-50%, -75%);
background: #000;
}
.wave:before {
border-radius: 45%;
background: rgb(255, 255, 255);
animation: animate 5s linear infinite;
}
.wave:after {
border-radius: 40%;
background: rgb(255, 255, 255, 0.5);
animation: animate 10s linear infinite;
}
#keyframes animate {
0% {
transform: translate(-50%, var(--water)) rotate(0deg);
}
100% {
transform: translate(-50%, var(--water)) rotate(360deg);
}
}
I tried putting translate: transform 2s linear but that didnt work for me eighter do you guys have any idea beaces when i change the
:root {
--water: -90%
}
to
:root {
--water: -80%
}
it will just snap and not animate

How to add gradient to the triangle?

How would I be able to apply a gradient color to the triangle?
https://jsfiddle.net/otz9ewm8/
.spinner::before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 27px solid #B76BF0;
transform: translateX(4px);
z-index: 0;
}
How would this be done in the code?
.spinner {
-webkit-appearance: none;
appearance: none;
border: none;
padding: 0;
display: block;
cursor: pointer;
/*background: rgba(255, 255, 255, 0.1);*/
position: fixed;
left: 0;
top: 0;
bottom: 0;
right: 0;
margin: auto;
box-sizing: border-box;
background-clip: padding-box;
/* -webkit-mask: linear-gradient(rgba(0, 0, 0, 0.1), #000000 90%);*/
width: 90px;
height: 90px;
border-radius: 50%;
transform-origin: 50% 55%;
transform: perspective(90px) rotateX(30deg);
animation: spinner-wiggle 5.2s infinite;
}
.spinner::before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 27px solid #B76BF0;
transform: translateX(4px);
z-index: 0;
}
#keyframes spinner-wiggle {
30% {
transform: perspective(90px) rotateX(10deg);
}
40% {
transform: perspective(90px) rotateX(7deg);
}
50% {
transform: perspective(90px) rotateX(10deg);
}
60% {
transform: perspective(90px) rotateX(8deg);
}
}
.color-circle {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
width: 90px;
height: 90px;
transform-origin: 50% 50%;
background: -webkit-gradient(linear,
left top,
left bottom,
color-stop(50%, #25d8fb),
color-stop(100%, #4f66bb));
border-radius: 50%;
z-index: 0;
box-shadow: inset 0 24px 18px -10px rgba(0, 0, 140, 0.3),
inset 0 0 22px -2px rgba(0, 0, 0, 0.4);
cursor: pointer;
background: linear-gradient(100deg, #24A4EA, #379DEB 25%, #B76BF0);
-webkit-mask-image: radial-gradient(circle, transparent 0 36px, black 36px);
mask-image: radial-gradient(circle, transparent 0 50px, black 20px);
}
.spinner:hover .color-circle {
background: -webkit-gradient(linear,
left top,
left bottom,
color-stop(50%, rgba(34, 204, 0, 0.9)),
color-stop(100%, #55ff00));
}
.color-circle:before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
width: 72px;
height: 72px;
border-radius: 50%;
background-color: #353198;
z-index: 0;
}
.spinner:hover .color-circle {
animation: spin 1.7s infinite linear;
}
#-webkit-keyframes spin {
0% {
transform: rotateZ(0deg);
}
100% {
transform: rotateZ(360deg);
}
}
<div class=" spinner">
<span class="color-circle"></span>
</div>
You can use clip-path instead of borders
background-image: linear-gradient(100deg, #24A4EA, #379DEB 25%, #B76BF0);
clip-path: polygon(0% 0%, 100% 50%, 0% 100%);

:after doesn't scope by relative of parent

I have :after for my animation, as you can see it isn't scoped by the relative. What I want is the bar should start from the width of the bar itself, now it's from the far left. What's the issue here?
.loading {
position: relative;
background-color: #E2E2E2;
&::after {
display: block;
content: '';
position: absolute;
width: 100%;
height: 100%;
transform: translateX(-100%);
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .4), transparent);
animation: loading 1s infinite;
}
}
https://media.giphy.com/media/Vek3fMxjoA4qxGveZr/giphy.gif
try to inspect the :after DOM in this demo
https://codepen.io/eldyvoon/pen/vMVgaO
Try to add overflow:hidden to .loading
furthermore, you can see it works well with changing ::after' background-color
.loading {
position: relative;
background-color: #E2E2E2;
overflow: hidden;
&::after {
display: block;
content: '';
position: absolute;
width: 100%;
height: 100%;
transform: translateX(-100%);
background: linear-gradient(90deg, transparent, rgba(100, 255, 255, .4), transparent);
animation: loading 1s infinite;
}
}
do not use transform: translateX(-100%), it will start from outside left of your .loading, and add left: 0
.loading {
position: relative;
background-color: #E2E2E2;
overflow: hidden;
&::after {
display: block;
content: '';
position: absolute;
width: 100%;
left: 0;
height: 100%;
/* transform: translateX(-100%); */
background: linear-gradient(90deg, transparent, rgba(100, 255, 255, .4), transparent);
animation: loading 1s infinite;
}
}

Simple loading bar

I'm trying to make a simple download bar, but it turns out only a solid color without transition animation.
In addition, the "repeating-linear-gradient" does not work and I cannot understand why.
I am hope for your help. Thank you!
.Download {
height: 80px;
width: 1000px;
border: 2px solid black;
border-radius: 100px;
/*background: repeating-linear-graient (90deg, blue, red, 100px);*/
background: linear-gradient(to left, blue, red);
animation-name: download;
animation-direction: 10s;
animation-timing-function: linear;
animation-direction: normal;
}
#keyframes download {
0% {
left: -100%;
}
100% {
left: 100%;
}
}
<div class="Download">
</div>
You can use pseudo code to achieve this.
.Download {
height: 80px;
width: 1000px;
border: 2px solid black;
border-radius: 100px;
position: relative;
overflow: hidden;
}
.Download:after {
content: "";
position: absolute;
background-image: linear-gradient(to left, blue, red);
width: 100%;
height: 100%;
top: 0;
left: -100%;
animation: download 5s;
}
#keyframes download {
0% {
left: -100%;
}
100% {
left: 0%;
}
}
<div class="Download">
</div>
You need to make half the linear gradient transparent (a bit list to prevent a hole in the end). Set the background position x to 100% to present only the transparent part. Then animation to 0:
.Download {
height: 80px;
width: 1000px;
border: 2px solid black;
border-radius: 100px;
background: linear-gradient(to right, red 0, blue 50.02%, transparent 50.02%) no-repeat;
animation: download 10s forwards;
background-position: 100% 0;
background-size: 200% 100%;
}
#keyframes download {
to {
background-position: 0 0;
}
}
<div class="Download">
</div>

Faded border loading spinner in CSS

How can I make the last part of the spinner lighter (ie. fading):
#loader-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1000;
}
#loader {
display: block;
position: relative;
left: 50%;
top: 50%;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border-radius: 50%;
border: 5px solid transparent;
border-top-color: #aaa;
border-right-color: #aaa;
animation: spin 2s linear infinite;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div id="loader-wrapper">
<div id="loader"></div>
</div>
I tried using gradient but it converts it to a square
You can apply the gradient to a pseudo-element like so:
#loader-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1000;
}
#loader {
display: block;
position: relative;
left: 50%;
top: 50%;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border-radius: 50%;
border: 5px solid transparent;
border-top-color: #aaa;
border-right-color: #aaa;
animation: spin 2s linear infinite;
}
#loader::after {
content: '';
width: 85%;
height: 85%;
background: linear-gradient(45deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 1) 40%, rgba(255, 255, 255, 0.7) 60%, rgba(255, 255, 255, 0) 100%);
position: absolute;
top: 0;
left: 0;
transform: translate(-5%, -5%);
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div id="loader-wrapper">
<div id="loader"></div>
</div>
Here is another idea with less code and without using pseudo element.
.loader {
--border-width: 5px;
height: 150px;
width: 150px;
border-radius: 50%;
/* 0.5px's are needed to avoid hard-stopping */
--mask: radial-gradient(
farthest-side,
transparent calc(100% - var(--border-width) - 0.5px),
#000 calc(100% - var(--border-width) + 0.5px)
);
-webkit-mask: var(--mask);
mask: var(--mask);
background: linear-gradient(#aaa 30%, transparent 80%) 0 0/50% 100% no-repeat; /* this is our border image */
animation: spin 2s linear infinite;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div class="loader"></div>
And this is the comparison of my answer with #Ricky's answer by setting background to body:
#Ricky's way:
body {
background: pink; /* just added this */
}
#loader-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1000;
}
#loader {
display: block;
position: relative;
left: 50%;
top: 50%;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border-radius: 50%;
border: 5px solid transparent;
border-top-color: #aaa;
border-right-color: #aaa;
animation: spin 2s linear infinite;
}
#loader::after {
content: '';
width: 85%;
height: 85%;
background: linear-gradient(45deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 1) 40%, rgba(255, 255, 255, 0.7) 60%, rgba(255, 255, 255, 0) 100%);
position: absolute;
top: 0;
left: 0;
transform: translate(-5%, -5%);
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div id="loader-wrapper">
<div id="loader"></div>
</div>
My way:
body {
background: pink; /* just added this */
}
.loader {
--border-width: 5px;
height: 150px;
width: 150px;
border-radius: 50%;
/* 0.5px's are needed to avoid hard-stopping */
--mask: radial-gradient(
farthest-side,
transparent calc(100% - var(--border-width) - 0.5px),
#000 calc(100% - var(--border-width) + 0.5px)
);
-webkit-mask: var(--mask);
mask: var(--mask);
background: linear-gradient(#aaa 30%, transparent 80%) 0 0/50% 100% no-repeat; /* this is our border image */
animation: spin 2s linear infinite;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div class="loader"></div>

Resources