CSS Animation rotate3d not working in Safari - html

I cannot get this animation to work in Safari 12 no matter what I try. I've tried vendor prefixes and all, but nothing works.
It works fine in Chrome. Anyone have any ideas?
<div class="spinners"></div>
This is the css:
#keyframes spinx {
0% {
transform: rotate3d(0, 1, 1, 360deg);
}
100% {
transform: rotate3d(0, 0, 0, 360deg);
}
}
.spinners {
display: block;
width: 100%;
height: 4rem;
overflow: hidden;
position: relative;
}
.spinners:before, .spinners:after {
content: "";
width: 4rem;
height: 4rem;
border: 3px solid red;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
margin: -2rem 0 0 -2rem;
display: block;
transform-origin: 50% 50% 0;
}
.spinners:before {
animation: spinx 2s infinite linear;
}
.spinners:after {
border-color: blue;
animation: spinx 4s infinite linear alternate;
}
Here's a demo:
https://codepen.io/Skinner927/pen/vVEdag

Seems like both Safari and Firefox don't recognise the change between the two key frames. To solve this you can use an intermediate keyframe:
50% {
transform: rotate3d(0, 1, 1, 180deg);
}
Demo:
#keyframes spinx {
0% {
transform: rotate3d(0, 1, 1, 360deg);
}
50% {
transform: rotate3d(0, 1, 1, 180deg);
}
100% {
transform: rotate3d(0, 0, 0, 0);
}
}
.spinners {
display: block;
width: 100%;
height: 4rem;
overflow: hidden;
position: relative;
}
.spinners:before,
.spinners:after {
content: "";
width: 4rem;
height: 4rem;
border: 3px solid red;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
margin: -2rem 0 0 -2rem;
display: block;
transform-origin: 50% 50% 0;
}
.spinners:before {
animation: spinx 2s infinite linear;
}
.spinners:after {
border-color: blue;
animation: spinx 4s infinite linear alternate;
}
<div class="box">
<div class="spinners"></div>
</div>

Related

How do you properly size and fit a gif to Youtube's video player via CSS?

I want to make a theme for Youtube using Stylish. Currently, I'm trying to make replace the spinner that appears while buffering with a gif. However, I can't seem to figure out how to properly adjust the size of the gif. I've gotten pretty close but I can't seem to actually resize the gif or move it all the way to the left.
Here's where I got the HTML and original CSS: https://codepen.io/Webevasion/pen/VQEdRd
Here's the CSS I came up with:
.ytp-spinner {
position: relative;
width: 100%;
margin-left: 0;
z-index: none;
pointer-events: none;
}
.ytp-spinner-container {
background: url("url to background here");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
background-size: auto;
pointer-events: none;
position: absolute;
width: 100%;
padding-bottom: 100%;
top: 50%;
left: 50%;
margin-top: -50%;
margin-left: -50%;
animation: none;
-webkit-animation: none;
}
.ytp-spinner-rotator {
display: none;
position: absolute;
width: 100%;
height: 100%;
-webkit-animation: ytp-spinner-easespin 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
animation: ytp-spinner-easespin 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
}
.ytp-spinner-left {
position: absolute;
top: 0;
left: 0;
bottom: 0;
overflow: hidden;
}
.ytp-spinner-right {
position: absolute;
top: 0;
right: 0;
bottom: 0;
overflow: hidden;
}
.ytp-spinner-left {
right: 0%;
}
.ytp-spinner-right {
left: 0%;
}
.ytp-spinner-circle {
box-sizing: border-box;
position: absolute;
width: 200%;
height: 100%;
border-style: solid;
border-color: #ddd #ddd transparent;
border-radius: 50%;
border-width: 6px;
}
.ytp-spinner-left .ytp-spinner-circle {
left: 0;
right: 0%;
border-right-color: transparent;
-webkit-animation: ytp-spinner-left-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
animation: ytp-spinner-left-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
}
.ytp-spinner-right .ytp-spinner-circle {
left: 0%;
right: 0;
border-left-color: transparent;
-webkit-animation: ytp-right-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
animation: ytp-right-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
}
#-webkit-keyframes ytp-spinner-linspin {
to {
-webkit-transform: rotate(360deg);
}
}
#keyframes ytp-spinner-linspin {
to {
transform: rotate(360deg);
}
}
#-webkit-keyframes ytp-spinner-easespin {
12.5% {
-webkit-transform: rotate(135deg);
}
25% {
-webkit-transform: rotate(270deg);
}
37.5% {
-webkit-transform: rotate(405deg);
}
50% {
-webkit-transform: rotate(540deg);
}
62.5% {
-webkit-transform: rotate(675deg);
}
75% {
-webkit-transform: rotate(810deg);
}
87.5% {
-webkit-transform: rotate(945deg);
}
to {
-webkit-transform: rotate(1080deg);
}
}
#keyframes ytp-spinner-easespin {
12.5% {
transform: rotate(135deg);
}
25% {
transform: rotate(270deg);
}
37.5% {
transform: rotate(405deg);
}
50% {
transform: rotate(540deg);
}
62.5% {
transform: rotate(675deg);
}
75% {
transform: rotate(810deg);
}
87.5% {
transform: rotate(945deg);
}
to {
transform: rotate(1080deg);
}
}
#-webkit-keyframes ytp-spinner-left-spin {
0% {
-webkit-transform: rotate(130deg);
}
50% {
-webkit-transform: rotate(-5deg);
}
to {
-webkit-transform: rotate(130deg);
}
}
#keyframes ytp-spinner-left-spin {
0% {
transform: rotate(130deg);
}
50% {
transform: rotate(-5deg);
}
to {
transform: rotate(130deg);
}
}
#-webkit-keyframes ytp-right-spin {
0% {
-webkit-transform: rotate(-130deg);
}
50% {
-webkit-transform: rotate(5deg);
}
to {
-webkit-transform: rotate(-130deg);
}
}
#keyframes ytp-right-spin {
0% {
transform: rotate(-130deg);
}
50% {
transform: rotate(5deg);
}
to {
transform: rotate(-130deg);
}
}
#import url('https://fonts.googleapis.com/css?family=Roboto');
body {
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
min-height: 250px;
padding-top: 20px;
font-weight: bold;
background: #f0f0f0;
}
.infos {
width: 500px;
text-align: center;
font-family: 'Roboto', Arial;
font-size: 14px;
line-height: 16px;
margin-top: 50px;
color: #000;
}
.infos a {
color: #555;
text-decoration: none;
}
.infos a:hover {color: #999;}
It's currently oversized and only covers half of the gif. Please, how do I make the whole thing show up and fit inside of the video player perfectly. The ratio should be the same as the player already, I just can't figure out how to properly adjust it.
Major issue I had: you have to utilize the existing CSS and alter it rather than delete it. If you don't overwrite it, it'll persist.
Positioning was the issue.
The positioning in the CSS was not optimal. Changing the top, left, and margin properties to 0px and setting the position of the container worked extremely well.
Working CSS:
.ytp-spinner {
border-style: solid;
border-color: lime;
position: static;
left: 50%;
top: 50%;
width: 100%;
margin-left: 0px;
z-index: 0;
pointer-events: none
}
.ytp-spinner-container {
border-style: solid;
border-color: lime;
background: url("url to background here");
background-repeat: no-repeat;
background-attachment: relative;
background-position: center;
background-size: auto;
pointer-events: none;
position: absolute;
width: 100%;
padding-bottom: 100%;
top: 50%;
left: 0px;
margin-top: -50%;
margin-left: 0px;
animation: none;
}
.ytp-spinner-rotator {
display: none;
position: absolute;
width: 100%;
height: 100%;
animation: none;
}
.ytp-spinner-left {
position: absolute;
top: 0;
left: 0;
bottom: 0;
overflow: hidden
}
.ytp-spinner-right {
position: absolute;
top: 0;
right: 0;
bottom: 0;
overflow: hidden
}
.ytp-spinner-left {
right: 49%
}
.ytp-spinner-right {
left: 49%
}
.ytp-spinner-circle {
box-sizing: border-box;
position: absolute;
width: 200%;
height: 100%;
border-style: solid;
border-color: #ddd #ddd transparent;
border-radius: 50%;
border-width: 6px
}
.ytp-spinner-left .ytp-spinner-circle {
left: 0;
right: -100%;
border-right-color: transparent;
animation: ytp-spinner-left-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
}
.ytp-spinner-right .ytp-spinner-circle {
left: -100%;
right: 0;
border-left-color: transparent;
animation: ytp-right-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
}
#keyframes ytp-spinner-linspin {
to {
transform: rotate(360deg)
}
}
#keyframes ytp-spinner-easespin {
12.5% {
transform: rotate(135deg)
}
25% {
transform: rotate(270deg)
}
37.5% {
transform: rotate(405deg)
}
50% {
transform: rotate(540deg)
}
62.5% {
transform: rotate(675deg)
}
75% {
transform: rotate(810deg)
}
87.5% {
transform: rotate(945deg)
}
to {
transform: rotate(1080deg)
}
}
#keyframes ytp-spinner-left-spin {
0% {
transform: rotate(130deg)
}
50% {
transform: rotate(-5deg)
}
to {
transform: rotate(130deg)
}
}
#keyframes ytp-right-spin {
0% {
transform: rotate(-130deg)
}
50% {
transform: rotate(5deg)
}
to {
transform: rotate(-130deg)
}
}

How to create a rainbow-colored circle using HTML and CSS?

I am trying to recreate this gif using HTML and CSS, but this is where I got stuck. Here is the gif:
https://www.link-elearning.com/linkdl/coursefiles/1452/ADCSS9_assigment_animation1.gif
This is what I have done so far but I am stuck:
<!DOCTYPE html>
<html>
<head>
<style>
.circle {
padding-top: 2px;
height: 300px;
width: 300px;
margin-left: auto;
margin-right: auto;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
animation: scaleIn 4s infinite cubic-bezier(.36, .11, .89, .32);
background: rgb(32, 6, 146)
}
#keyframes scaleIn {
from {
transform: scale(.5, .5);
opacity: .5;
}
to {
transform: scale(2.5, 2.5);
opacity: 0;
}
}
</style>
</head>
<body style="background-color:#050210;">
<div class="circle" style="animation-delay: -2s"></div>
<div class="circle" style="animation-delay: -1s"></div>
<div class="circle" style="animation-delay: -0"></div>
</body>
</html>
One method to get the rainbow coloured outlined is to use another div that sits behind the darker inner divs. This rainbow coloured outline can be achieved by using a linear-gradient. All the CSS animations are set to infinite to allow them to run repeatedly. Here I used some CSS variables to set the sizes of the circles indicated by -- in front of the variable name. It's good to note that it might be a good idea to put this in a wrapper/container div instead of the absolute positioning I have below. The pulsing in the centre could also use some adjustments. Press the Run code snippet button below to see the results:
body {
background: rgba(6, 2, 20, 1);
}
#Blurry_Rainbow_Circle {
position: absolute;
--Circle_Diameter: 200px;
top: calc(50% - var(--Circle_Diameter)/2);
left: calc(50% - var(--Circle_Diameter)/2);
height: var(--Circle_Diameter);
width: var(--Circle_Diameter);
border-radius: calc(var(--Circle_Diameter)/2);
background: linear-gradient(139.84deg, #A692ED 14.35%, #6CECAD 45.6%, #D87EAA 82.79%);
animation: Rotate 0.8s linear infinite;
filter: blur(20px);
}
#Rainbow_Circle {
position: absolute;
--Circle_Diameter: 200px;
top: calc(50% - var(--Circle_Diameter)/2);
left: calc(50% - var(--Circle_Diameter)/2);
height: var(--Circle_Diameter);
width: var(--Circle_Diameter);
border-radius: calc(var(--Circle_Diameter)/2);
background: linear-gradient(139.84deg, #A692ED 14.35%, #6CECAD 45.6%, #D87EAA 82.79%);
animation: Rotate 0.8s linear infinite;
}
#Large_Circle {
position: absolute;
--Circle_Diameter: 175px;
top: calc(50% - var(--Circle_Diameter)/2);
left: calc(50% - var(--Circle_Diameter)/2);
height: var(--Circle_Diameter);
width: var(--Circle_Diameter);
border-radius: calc(var(--Circle_Diameter)/2);
background: rgba(6, 2, 20, 1);
}
#Medium_Circle {
position: absolute;
--Circle_Diameter: 10px;
top: calc(50% - var(--Circle_Diameter)/2);
left: calc(50% - var(--Circle_Diameter)/2);
height: var(--Circle_Diameter);
width: var(--Circle_Diameter);
border-radius: calc(var(--Circle_Diameter)/2);
background: rgba(19, 12, 49, 1);
animation: Grow 2s linear infinite;
}
#Small_Circle {
position: absolute;
--Circle_Diameter: 10px;
top: calc(50% - var(--Circle_Diameter)/2);
left: calc(50% - var(--Circle_Diameter)/2);
height: var(--Circle_Diameter);
width: var(--Circle_Diameter);
border-radius: calc(var(--Circle_Diameter)/2);
background: rgba(19, 12, 49, 1);
animation: Grow_2 2s linear infinite;
}
#keyframes Rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#keyframes Grow {
0% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(17);
opacity: 0;
}
51% {
transform: scale(0);
opacity: 0;
}
100% {
transform: scale(0);
opacity: 0;
}
}
#keyframes Grow_2 {
0% {
transform: scale(0);
opacity: 0;
}
40% {
transform: scale(0);
opacity: 0;
}
41% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(17);
opacity: 0;
}
}
<div id="Blurry_Rainbow_Circle"></div>
<div id="Rainbow_Circle"></div>
<div id="Large_Circle"></div>
<div id="Medium_Circle"></div>
<div id="Small_Circle"></div>
I dont know where u study.. but it is one hell of a study.... Itadakimas... Thanks for the meal... I loved working on it
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.body {
background-color: #050210;
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.circle {
position: absolute;
height: 230px;
width: 230px;
border-radius: 50%;
background: rgb(32, 6, 146)
}
.animate {
transform: translate(-50%, -50%);
animation: scaleIn 1.9s infinite;
}
.border {
/* --b: 5px; */
/* border width*/
animation: rotate 3s infinite linear;
z-index: 0;
/* scale: 4.5; */
--b: 10px;
--c: linear-gradient(140deg, red, yellow, green);
background: transparent;
box-shadow: 5px 5px 19px #54aa00, -5px -5px 19px #ff5a00, -5px 5px 19px #f9e203, 5px -5px 19px #f9e203;
}
.border:after {
content: "";
display: inline-block;
padding-top: 100%;
}
.border:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--c, linear-gradient(to right, #9c20aa, #fb3570));
padding: var(--b);
border-radius: 50%;
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
-webkit-mask-composite: destination-out;
mask-composite: exclude;
}
#keyframes scaleIn {
from {
transform: scale(.15, .15);
opacity: .5;
}
to {
transform: scale(1, 1);
opacity: 0;
}
}
#keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
<div class="body">
<div class="circle border"></div>
<div class="circle animate" style="animation-delay: -0.95s"></div>
<div class="circle animate" style="animation-delay: 0s"></div>
</div>
Whew,, Corrected all mistakes... didn't choose your color though

Center a text inside an spinning element

I have a simple loader animation and I want to add a loading text inside the circle.
As I'm spinning the .slide-loader and my text is inside it I've tried to exclude the .loader-text but it still spins?! how can I fix the loader-text inside the circle?
Here is the code:
.slide-loader:not(.loader-text) {
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
border: 6px solid #f3f3f3;
border-radius: 50%;
border-top: 6px solid #3498db;
width: 100px;
height: 100px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
#-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
#keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
<div class="slide-loader">
<div class="loader-text">Loading...</div>
</div>
try this code:
.slide-loader {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 100px;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
}
.spinner {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
border: 6px solid #f3f3f3;
border-radius: 50%;
border-top: 6px solid #3498db;
width: 100px;
height: 100px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
#-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div class="slide-loader">
<div class="spinner"></div>
<div class="loader-text">Loading...</div>
</div>
You can't..as such, if you rotate the parent you rotate the child. You need to rotate the text the other way at the same time.
Then center the text any way you wish, perhaps with flexbox....
.slide-loader {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
border: 6px solid #f3f3f3;
border-radius: 50%;
border-top: 6px solid #3498db;
width: 100px;
height: 100px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
display: flex;
justify-content: center;
align-items: center;
}
#-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.loader-text {
animation: spin 2s linear infinite reverse;
}
<div class="slide-loader">
<div class="loader-text">Loading...</div>
</div>
Use an absolutely positioned pseudo-element (::before) for the rotating area, and center the text with a flexbox:
.slide-loader {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 100px;
height: 100px;
}
.slide-loader::before {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
border: 6px solid #f3f3f3;
border-radius: 50%;
border-top: 6px solid #3498db;
animation: spin 2s linear infinite;
content: '';
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div class="slide-loader">Loading...</div>
The spinner and text can be siblings and you can center both relative to the parent:
.slide-loader {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 100px;
height: 100px;
}
.spinner {
width: 100px;
height: 100px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
border: 6px solid #f3f3f3;
border-radius: 50%;
border-top: 6px solid #3498db;
box-sizing: border-box;
position: absolute;
/*Center spinner with these 4 lines*/
top: 50%;
left: 50%;
margin-left: -50px;
margin-top: -50px;
}
.loader-text {
position: absolute;
/*Center text with these 3 lines*/
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div class="slide-loader">
<div class="spinner"></div>
<div class="loader-text">Loading...</div>
</div>
.slide-loader:not(.loader-text) {
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
border: 6px solid #f3f3f3;
border-radius: 50%;
border-top: 6px solid #3498db;
width: 100px;
height: 100px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
.container {
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
#-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
#keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
<div>
<div class="container">
<div class="loader-text">Loading...</div>
<div class="slide-loader">
</div>
</div>
</div>
Hi I made this work around and works perfectly.
<div class="container">
<div class="slide-loader"></div>
<div class="loader-text">Loading...</div>
</div>
.slide-loader{
grid-row: 1/-1;
grid-column: 1/-1;
margin: auto;
border: 6px solid #f3f3f3;
border-radius: 50%;
border-top: 6px solid #3498db;
width: 100px;
height: 100px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
.container{
width: 200px;
display: grid;
grid-template-rows: 1fr 20px 1fr;
grid-template-columns: auto 60px auto;
}
.loader-text{
grid-row: 2;
grid-column: 2;
}
#-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
#keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

css keyframe transform not rotating more than 180 degrees

I am trying to build a donut chart with css. I am observing that it is unable to rotate more than 180 degrees. Am I missing anything.
This stops me to show donut chart for any data which is more than 50%.
http://jsfiddle.net/BkJY7/80/
#-webkit-keyframes rotate-rt {
0% { -webkit-transform: rotate(0deg); }
25% { -webkit-transform: rotate(360deg); }
100% { -webkit-transform: rotate(360deg); }
}
You are missing the keyframes for rotate-lt.
Also, some minor adjustments on the angles:
body {
margin: 50px;
}
.spinner {
width: 250px;
height: 250px;
background: #aaa;
margin: 0 auto;
position: relative;
}
.spinner:after {
position: absolute;
content: "";
width: 0%;
height: 0%;
border-radius: 100%;
background: #fff;
top: 10%;
left: 10%;
}
.spinner span em {
background: #0e728e;
-webkit-animation-duration: 6s;
}
#-webkit-keyframes rotate-rt {
0% { -webkit-transform: rotate(0deg); }
50% { -webkit-transform: rotate(180deg); }
100% { -webkit-transform: rotate(180deg); }
}
#-webkit-keyframes rotate-lt {
0% { -webkit-transform: rotate(0deg); }
50% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(180deg); }
}
.spinner {
border-radius: 100%;
position: relative;
}
.spinner span {
width: 50%;
height: 100%;
overflow: hidden;
position: absolute;
}
.spinner span:first-child {
left: 0;
}
.spinner span:last-child {
left: 50%;
}
.spinner span em {
border-radius: 250px;
position: absolute;
width: 100%;
height: 100%;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: linear;
-webkit-animation-fill-mode: forwards;
}
.spinner span:first-child em {
left: 100%;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
-webkit-animation-name: rotate-lt;
-webkit-transform-origin: 0 50%;
}
.spinner span:last-child em {
left: -100%;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
-webkit-animation-name: rotate-rt;
-webkit-transform-origin: 100% 50%;
}
<div class="spinner">
<span><em></em></span>
<span><em></em></span>
</div>
I would try to use this from css-tricks to achieve what you want:
https://codepen.io/HugoGiraudel/pen/BHEwo
Tutorial:
https://css-tricks.com/css-pie-timer/
html:
<div class="wrapper">
<div class="pie spinner"></div>
<div class="pie filler"></div>
<div class="mask"></div>
</div>
css:
.wrapper {
position: relative;
margin: 40px auto;
background: white;
}
.wrapper, .wrapper * {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.wrapper {
width: 250px;
height: 250px;
}
.wrapper .pie {
width: 50%;
height: 100%;
transform-origin: 100% 50%;
position: absolute;
background: #08C;
border: 5px solid rgba(0,0,0,0.5);
}
.wrapper .spinner {
border-radius: 100% 0 0 100% / 50% 0 0 50%;
z-index: 200;
border-right: none;
animation: rota 5s linear infinite;
}
.wrapper:hover .spinner,
.wrapper:hover .filler,
.wrapper:hover .mask {
animation-play-state: running;
}
.wrapper .filler {
border-radius: 0 100% 100% 0 / 0 50% 50% 0;
left: 50%;
opacity: 0;
z-index: 100;
animation: opa 5s steps(1, end) infinite reverse;
border-left: none;
}
.wrapper .mask {
width: 50%;
height: 100%;
position: absolute;
background: inherit;
opacity: 1;
z-index: 300;
animation: opa 5s steps(1, end) infinite;
}
#keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
#keyframes opa {
0% {
opacity: 1;
}
50%, 100% {
opacity: 0;
}
}
Also you can check this out also nice tutorial:
http://javabeat.net/pie-chart-css3-html/
Keep in mind I take no credit for writing this code, just helpin.
you add keyframe only for rotate-rt that why its rotate half
add a keyframe for rotate-lt so get the better result
#-webkit-keyframes rotate-lt {
0% { -webkit-transform: rotate(0deg); }
25% { -webkit-transform: rotate(180deg); }
100% { -webkit-transform: rotate(360deg); }
}

Center div inside div

I know it's a noob questioin but I got stuck on this thing.
How to center vertically and horizontally "slide-loading" div in this situation?
.blueimp-gallery > .slides > .slide-loading
Element with class "blueimp-gallery" has position fixed.
Element with class "slides" has position relative.
Element with class "slide-loading" is a simple CSS preloader (without specified position).
.blueimp-gallery > .slides > .slide-loading {
border: 4px solid #f3f3f3;
border-radius: 50%;
border-top: 4px solid #3498db;
width: 60px;
height: 60px;
-webkit-animation: spin 1s linear infinite;
animation: spin 1s linear infinite;
}
#-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
#keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
SOLUTION:
You can achieve this using the transform css property, using the following:
position: absolute;
top: calc(50% - 30px); //minus half the height of your spinner (30px)
left: calc(50% - 30px); //minus half the width of your spinner (30px)
transform: translate(-50%, -50%);
jsFIDDLE
CODE SNIPPET:
body {
margin: 0;
}
* {
box-sizing: border-box;
}
.rulerX,
.rulerY {
position: absolute;
z-index: 9999;
background-color: red;
}
.rulerX {
top: calc(50% - .5px);
height: 1px;
width: 100%;
}
.rulerY {
left: calc(50% - .5px);
width: 1px;
height: 100%;
}
.blueimp-gallery {
position: relative;
border: 3px solid royalblue;
height: 100vh;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}
.slides {
height: 100%;
border: 3px dotted white;
position: relative;
background-color: #262626;
}
#-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.blueimp-gallery > .slides > .slide-loading {
border: 4px solid #f3f3f3;
border-radius: 50%;
border-top: 4px solid #3498db;
width: 60px;
height: 60px;
-webkit-animation: spin 1s linear infinite;
animation: spin 1s linear infinite;
position: absolute;
top: calc(50% - 30px);
left: calc(50% - 30px);
transform: translate(-50%, -50%);
}
<div class="blueimp-gallery">
<div class="rulerX"></div>
<div class="rulerY"></div>
<div class="slides">
<div class="slide-loading">
</div>
</div>
</div>