Loader timing issues - html

I am confused why the after selector is moving faster than the no selector div, can anyone explain why this is the case? The before and after selectors are working perfectly but I cannot seem to edit the actual main div I have the selectors off of. I am kinda new at this and apologize for poor formatting or anything of that sort, But I would greatly appreciate some help on this! I want the inner cicle to move the fastest, the middle to move slower, and the outer the slowest.
https://jsfiddle.net/wnmsfudo/1/
html,
body {
height: 100vh;
width: 100vw;
}
.loader {
margin-top: -80px;
content: "";
display: block;
position: absolute;
top: 50vh;
left: 46vw;
width: 100px;
height: 100px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: red;
animation: spin 2s linear infinite;
}
.loader::before {
content: "";
display: block;
position: absolute;
top: 12.5px;
left: 12.5px;
width: 75px;
height: 75px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: green;
animation: spin 1s linear infinite;
}
.loader::after {
content: "";
display: block;
position: absolute;
top: -12.5px;
left: -12.5px;
width: 125px;
height: 125px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: blue;
animation: spin 3s linear infinite;
}
#keyframes spin {
0% {
-webkit-transform: rotate(0deg);
/* Chrome, Opera 15+, Safari 3.1+ */
-ms-transform: rotate(0deg);
/* IE 9 */
transform: rotate(0deg);
/* Firefox 16+, IE 10+, Opera */
}
100% {
-webkit-transform: rotate(360deg);
/* Chrome, Opera 15+, Safari 3.1+ */
-ms-transform: rotate(360deg);
/* IE 9 */
transform: rotate(360deg);
/* Firefox 16+, IE 10+, Opera */
}
}
<div class="container">
<div class="loader"></div>
</div>

The issue is that the entire .loader div rotates once every 2 seconds, and that the ::before and ::after pseudo elements therefore rotate with it. Their own rotation is added to the parent's!
So the solution is to adapt the pseudo-elements' rotations so that they move relatively to the main element. The ::after even needs to rotate in reverse if you want to make it appear slower.
html, body {
height: calc(100% - 16px);
}
.loader {
margin-top: -80px;
content: "";
display: block;
position: absolute;
top: 50vh;
left: 46vw;
width: 100px;
height: 100px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: red;
animation: spin 2s linear infinite;
}
.loader::before {
content: "";
display: block;
position: absolute;
top: 12.5px;
left: 12.5px;
width: 75px;
height: 75px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: green;
animation: spin 5s linear infinite;
}
.loader::after {
content: "";
display: block;
position: absolute;
top: -12.5px;
left: -12.5px;
width: 125px;
height: 125px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: blue;
animation: spin 5s linear reverse infinite;
}
#keyframes spin {
0% {
-webkit-transform: rotate(0deg);
/* Chrome, Opera 15+, Safari 3.1+ */
-ms-transform: rotate(0deg);
/* IE 9 */
transform: rotate(0deg);
/* Firefox 16+, IE 10+, Opera */
}
100% {
-webkit-transform: rotate(360deg);
/* Chrome, Opera 15+, Safari 3.1+ */
-ms-transform: rotate(360deg);
/* IE 9 */
transform: rotate(360deg);
/* Firefox 16+, IE 10+, Opera */
}
}
<div class="container">
<div class="loader">
</div>
</div>

Related

iPhone (Safari and Chrome both) position: fixed bug?

I have this website
On desktop everything works fine, but on iPhone (Safari and Chrome both) I have problem with preloader:
Bug screenshot
CSS:
.preloader_wrapper {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: #000;
z-index: 100500;
}
.preloader {
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 50%;
width: 50px;
height: 50px;
}
.preloader::before {
content: '';
position: absolute;
box-sizing: border-box;
top: 0;
left: 0;
width: 50px;
height: 50px;
border-radius: 50%;
border: 4px solid #951b25;
border-left-color: transparent;
border-right-color: transparent;
animation: spin 1s linear infinite;
}
#keyframes spin {
0% {
transform: rotate(0deg) scale(1);
}
50% {
transform: rotate(45deg) scale(1.2);
}
100% {
transform: rotate(360deg) scale(1);
}
}
HTML:
<div class="preloader_wrapper">
<div class="preloader"></div>
</div>
Due to my googling I think the problem is in position fixed. How to solve it?
Hmm, I think .preloader absolute positing might fix it. I'm on a phone right now so can't test it. Otherwise I suggest to try display; flex; with justify and alignment props on the .preloader_wrapper and remove all the positioning stuff from the .preloader itself.

Why doesn't my animation work in ie 11

I have the following animation (fiddle):
<style style="text/css">
#AdvertBox {
height: 55px;
overflow: hidden;
position: relative;
background:black;
color: white;
border: 1.75px solid yellow;
font-size: 35px;
font-style: italic;
border-radius: 1px;
width:45vw;
}
.scroll-left p
{
position: absolute;
width: 100%;
height: 100%;
margin: 0;
line-height: 55px;
text-align: center;
/* Starting position */
transform:translateX(100%);
/* Apply animation to this element */
animation: scroll-left 10s linear infinite;
}
#keyframes scroll-left {
0% {
transform: translateX(100%);
}
25% {
opacity: 1;
transform: translateX(0%);
}
39% {
opacity: 0;
transform: translateX(0%);
}
100% {
opacity: 0;
transform: translateX(0%);
}
}
.popIn p
{
position: absolute;
width: 100%;
height: 100%;
margin: 0;
line-height: 55px;
text-align: center;
/* Starting position */
transform:translateY(-100%);
/* Apply animation to this element */
animation: popIn 10s linear infinite;
}
#keyframes popIn {
/* Move it left */
0% {
transform: translateY(-100%);
}
/* Stop It */
30% {
transform: translateY(-100%);
}
/* fade out */
42% {
transform: translateX(0%);
}
/* fade out */
70% {
transform: translateX(0%);
}
100% {
transform: translateX(-100%);
}
}
</style>
<div id="AdvertBox" >
<div class="scroll-left">
<p style="position: absolute; z-index: 1 ">
First Message
</p>
</div>
<div class="popIn">
<p style="position: absolute; z-index: 2 ">
Second, longer message to drop down
</p>
</div>
</div>
It should have one item slide in from the right, fade out, then one item drop down on it. It looks fine in chrome and firefox, and the first item that slides left works in ie, but the second item, dropping down, doesn't do anything.
i have updated your fiddle please have a look again, it works on IE 11, but you may need to tweak the animation.
basically instead of translateX and translateY, i used translate(x,y);
it worked on IE 11
ok i forked that old one and i created my own fiddle. so your popIn animation has been changed to the following.
#keyframes popIn {
/* Move it left */
0% {
transform: translate(0%,-100%);
}
/* fade out */
50% {
transform: translate(0%,0%);
}
/* fade out */
75% {
transform: translate(0%,0%);
}
100% {
transform: translate(-100%,0%);
}
}
https://jsfiddle.net/qvx4b311/

Transition animation need some CSS

I am trying to make a page load transition effective div. This is my DEMO FULL PAGE full page from codepen.io and also this is example page with code DEMO WITH CODE
If you open the demo full page then you can see there is a one image and this image opening with transition animation. But there is something went wrong.
When page load the image opening transition but it is opening up to bottom . I want to open it in the middle, without any deviation.
Anyone can help me in this regard ? How can i fixed it ?
This is my CSS code:
.test {
margin: 0px auto;
width: 200px;
height: auto;
margin-top: 50px;
}
.testtransition {
transform: scale(1.2);
width: 200px;
height: 200px;
margin: 0px auto;
margin-top: 50px;
overflow: hidden;
border-radius: 50%;
}
.testtransition img {
width: 100%;
max-width: 200px;
max-height: 200px;
opacity: 1;
-moz-animation: scale 0.8s;
/* Firefox */
-webkit-animation: scale 0.8s;
/* Safari and Chrome */
-o-animation: scale 0.8s;
border-radius: 50%;
-webkit-animation: scale 0.9s;
/* Safari, Chrome and Opera > 12.1 */
-moz-animation: scale 0.9s;
/* Firefox < 16 */
-ms-animation: scale 0.9s;
/* Internet Explorer */
-o-animation: scale 0.9s;
/* Opera < 12.1 */
animation: scale 0.9s;
}
#keyframes scale {
from {
width: 20px;
opacity: 0;
}
to {
width: 200px;
opacity: 1;
}
}
#-moz-keyframes scale {
/* Firefox */
from {
width: 20px;
opacity: 0;
}
to {
width: 200px;
opacity: 1;
}
}
#-webkit-keyframes scale {
/* Safari and Chrome */
from {
width: 20px;
opacity: 0;
}
to {
width: 200px;
opacity: 1;
}
}
#-o-keyframes scale {
/* Opera */
from {
width: 20px;
opacity: 0;
}
to {
width: 200px;
opacity: 1;
}
}
Here's a working pen. A summary of my changes:
Added text-align: center on .testtransition to keep the image centered
Added width, height, and padding to the animation to keep the image centered throughout the animation
Removed the width parameter from the img tag to keep things simple :)
This should do the trick! You need to set a from and to in each animation.
http://codepen.io/anon/pen/GJZvJB
.testtransition {
width: 200px;
height: 200px;
margin: 0px auto;
margin-top: 50px;
overflow: hidden;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
}
.testtransition img {
-webkit-animation: scaleAnim 1s;
-moz-animation: scaleAnim 1s;
-o-animation: scaleAnim 1s;
}
#-webkit-keyframes scaleAnim {
from { -webkit-transform: scale(0) }
to { -webkit-transform: scale(1) }
}
#-moz-keyframes scaleAnim {
from { -moz-transform: scale(0) }
to { -moz-transform: scale(1) }
}
#-o-keyframes scaleAnim {
from { -o-transform: scale(0)}
to { -o-transform: scale(1)}
}
You may have to play with the initial image to maintain an attractive circle, for now i've added backface-visibility.

display:table-cell not supported in Mozilla Firefox

I have a following div
<div>Circle</div>
I applied styles to the circle using the nth-child, the circle and the text inside it are supposed to spin. In the beginning, when I created the circle, I used
display:table-cell;
property to position the text in the center of the circle. When I run my page in Chrome, all the styles including the positioning look perfect. However, when I ran my code in Mozilla Firefox, I noticed that the positioning left and top don't work when I have display:table-cell; property set. They only work if I remove the display. However, if I remove the display, then my text is messy. In that case I decided to create a pseudo div. I managed to position the text in the the center of the circle, however, when I refresh the page, the spinning circle pushes to the right and the text doesn't spin. How can I fix this problem?
style.css
div:nth-child(3) {
width: 150px;
height: 150px;
background: -webkit-linear-gradient(#006600, #009900, #006600);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#006600, #009900, #006600);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#006600, #009900, #006600);
/* For Firefox 3.6 to 15 */
background: linear-gradient(#006600, #009900, #006600);
/* Standard syntax */
-moz-border-radius: 150px;
-webkit-border-radius: 150px;
border-radius: 150px;
text-align: center;
vertical-align: middle;
position: relative;
display:table-cell;
top: 5%;
left: 75px !important;
color: #F0F0F0;
font-size: 25px;
-webkit-animation-name: spin;
-webkit-animation-duration: 500ms;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: linear;
-moz-animation-name: spin;
-moz-animation-duration: 500ms;
-moz-animation-iteration-count: 1;
-moz-animation-timing-function: linear;
-ms-animation-name: spin;
-ms-animation-duration: 500ms;
-ms-animation-iteration-count: 1;
-ms-animation-timing-function: linear;
animation-name: spin;
animation-duration: 500ms;
animation-iteration-count: 1;
animation-timing-function: linear;
}
#-ms-keyframes spin {
from {
-ms-transform: rotate(0deg);
}
to {
-ms-transform: rotate(360deg);
}
}
#-moz-keyframes spin {
from {
-moz-transform: rotate(0deg);
}
to {
-moz-transform: rotate(360deg);
}
}
#-webkit-keyframes spin {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
#keyframes spin {
from {
transform:rotate(0deg);
}
to {
transform:rotate(360deg);
}
}
The following code is when I made a pseudo div, I did not include the css for spinning since it is the same as in the code above. The circle spins, but for that second that it spins it does to the right and then comes back. The text doesn't spin.
div:nth-child(3){
text-align:center;
position:relative;
width: 150px;
top: 50%;
left: 75%;
color: #F0F0F0;
font-size: 20px;
}
div:nth-child(3):after {
content: '';
width: 150px;
height: 150px;
position: absolute;
bottom: -80%;
left: 50%;
transform: translateX(-50%);
z-index: -1;
background: -webkit-linear-gradient(#006600, #009900, #006600);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#006600, #009900, #006600);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#006600, #009900, #006600);
/* For Firefox 3.6 to 15 */
background: linear-gradient(#006600, #009900, #006600);
/* Standard syntax */
-moz-border-radius: 150px;
-webkit-border-radius: 150px;
border-radius: 150px;
}
jsFiddle : http://jsfiddle.net/jLwmknk1/
Try applying this:
display: table;
table-layout: fixed;
instead of display:table-cell;

CSS transform and rotate with animation

HTML
<div id="div1">
<div id="div2">HELLO</div>
</div>
<div id="div3">
<div id="div4">HELLO</div>
</div>
CSS
#div1
{
position: relative;
height: 150px;
width: 150px;
margin: 50px;
padding:10px;
border: 1px solid black;
-webkit-perspective:150px; /* Chrome, Safari, Opera */
perspective:150px;
}
#div2
{
padding:50px;
position: absolute;
border: 1px solid black;
background-color: red;
-webkit-transform-origin:0%; /* Chrome, Safari, Opera */
-webkit-transform: rotateY(117deg); /* Chrome, Safari, Opera */
transform: rotateX(-75deg);
}
#div3
{
position: relative;
height: 150px;
width: 150px;
margin: 50px;
padding:10px;
border: 1px solid black;
-webkit-perspective:150px; /* Chrome, Safari, Opera */
perspective:150px;
}
#div4
{
padding:50px;
position: absolute;
border: 1px solid black;
background-color: red;
-webkit-transform-origin:0%; /* Chrome, Safari, Opera */
-webkit-transform: rotateY(0deg); /* Chrome, Safari, Opera */
transform: rotateX(-75deg);
}
Trying to do this rotate the inner div from starting position to final position with a delay 2
Two positions
Code for doing above got it from Here But its not working .What changes to make to make it work
-webkit-backface-visibility: visible;
-webkit-transform-origin: 0% 50%;
-webkit-transform: perspective(800px) rotateY(90deg) rotateY(-90deg);
Here: FIDDLE: http://jsfiddle.net/9dqAK/12/
HTML
<div id="stage">
<div id="spinner">
hello
</div>
</div>
CSS
#-webkit-keyframes spinner {
from {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(-360deg);
-moz-transform: rotateY(-360deg);
}
}
#spinner {
-webkit-transform-origin: 150px 0 0;
-webkit-animation-name: spinner;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 6s;
-webkit-transform-style: preserve-3d;
-moz-transform-origin: 150px 0 0;
-moz-animation-name: spinner;
-moz-animation-timing-function: linear;
-moz-animation-iteration-count: infinite;
-moz-animation-duration: 6s;
-moz-transform-style: preserve-3d;
padding:50px;
position: absolute;
border: 1px solid black;
background-color: red;
}
#spinner:hover {
-webkit-animation-play-state: paused;
}
You forgot to add when to do the animation. I assume that it is upon let's say hover.
So, add end styles to :hover pseudo-class. And, also specify some transition so that you can see it animating.
Demo: http://jsfiddle.net/abhitalks/WEX75/4/
CSS:
#div1 {
position: relative;
height: 150px;
width: 150px;
margin: 50px;
padding:10px;
border: 1px solid black;
-webkit-perspective:150px;
}
#div2 {
padding:50px;
position: absolute;
border: 1px solid black;
background-color: red;
-webkit-transform-origin:0%;
-webkit-transform: rotateY(117deg);
transition: 1s all;
}
#div1:hover > #div2 {
-webkit-backface-visibility: visible;
-webkit-transform-origin: 50% 50%;
-webkit-transform: perspective(500px) rotateY(0deg);
}
Edit: (After reading Op's comments somewhere above)
You want the animation to happen on page load. So, in that case just apply the relevant CSS using jQuery. Wrap that code in domready.
Demo 2: http://jsfiddle.net/abhitalks/WEX75/3/
JS:
$("#div2").css({
'-webkit-backface-visibility': 'visible',
'-webkit-transform-origin': '50% 50%',
'-webkit-transform': 'perspective(500px) rotateY(0deg)'
});
Edit 2:
You can introduce a delay of 2s by using transition-delay: 2s;.
Demo 3: http://jsfiddle.net/abhitalks/WEX75/5/
Add -webkit- to your last transform CSS declaration