CSS Animation when not hovering ov - html

I'm trying to make my logo grow when hovered over, but then revert back to the original size when the mouse is removed from the logo.
So far, the logo grows when the mouse is over it, but when you remove the mouse it just jumps back to the original size rather than shrinking gradually with the same effect.
http://jsfiddle.net/raahitsme/Fv577/
CSS:
body {
margin: 0;
padding: 0;
}
#font-face { font-family: Danube; src: url('../DANUBE__.TTF'); }
#font-face { font-family: Danube; font-weight: bold; src: url('../DANUB__.TTF');}
html, body, #background { height: 100%; }
body > #background { height: auto; min-height: 100%; }
#background
{
left: 0px;
top: 0px;
position: relative;
background-color: #303030;
padding-top: -51px;
}
#HeaderGrey
{
background-color: #676767;
height: 94px;
width: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin-top: 0px;
position: relative;
}
#HeaderShaderTop
{
background-color: #0e453d;
height: 2px;
width: 100%;
position: relative;
}
#HeaderShaderBottom
{
background-color: #009d89;
height: 2px;
width: 100%;
position: relative;
}
#HeaderLogo{
margin-top: 5px;
margin-left: 28px;
height: 85px;
width: 86px;
position: absolute;
-webkit-animation-name: pulse1;
animation-name: pulse1;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
#Title{
font-family: Danube;
font-size: 50px;
color: #c6c6c6;
text-align: right;
float: right;
margin-right: 16px;
margin-top: 7px;
padding-top: 0;
}
#footer{
background-color: #1f1f1f;
height: 51px;
width: 100%;
clear: both;
position: relative;
z-index: 10;
margin-top: -51px;
}
#-webkit-keyframes pulse0 {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
#keyframes pulse0 {
0% {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
}
.pulse0 {
-webkit-animation-name: pulse2;
animation-name: pulse2;
}
#-webkit-keyframes pulse2 {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
}
#keyframes pulse2 {
0% {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
}
}
.pulse2 {
-webkit-animation-name: pulse2;
animation-name: pulse2;
}
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
#HeaderLogo:hover{
-webkit-animation-name: pulse2;
animation-name: pulse2;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}

You should use transition instead of animation. Here is an updated version of your code: http://jsfiddle.net/maximgladkov/k8kX4/1/
#HeaderLogo{
-webkit-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
-webkit-transform: scale(1.0);
-ms-transform: scale(1.0);
transform: scale(1.0);
}
#HeaderLogo:hover{
-webkit-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
}

Related

Why progress bar is displaying differently for same value?

I am working on circular progress bar using HTML & CSS. HTML content is under for loop. Here, I tried with same 5% but the result of progress is different
.progress{
width: 120px;
height: 120px;
line-height: 120px;
background: none;
margin: 0 auto;
box-shadow: none;
position: relative;
}
.progress:after{
content: "";
width: 100%;
height: 100%;
border-radius: 50%;
border: 15px solid #f2f5f5;
position: absolute;
top: 0;
left: 0;
}
.progress > span{
width: 50%;
height: 100%;
overflow: hidden;
position: absolute;
top: 0;
z-index: 1;
}
.progress .progress-left{
left: 0;
}
.progress .progress-bar{
width: 100%;
height: 100%;
background: none;
border-width: 12px;
border-style: solid;
position: absolute;
top: 0;
}
.progress .progress-left .progress-bar{
left: 100%;
border-top-right-radius: 80px;
border-bottom-right-radius: 80px;
border-left: 0;
-webkit-transform-origin: center left;
transform-origin: center left;
}
.progress .progress-right{
right: 0;
}
.progress .progress-right .progress-bar{
left: -100%;
border-top-left-radius: 80px;
border-bottom-left-radius: 80px;
border-right: 0;
-webkit-transform-origin: center right;
transform-origin: center right;
animation: loading-1 1.8s linear forwards;
}
.progress .progress-value{
width: 100%;
height: 100%;
font-size: 14px;
font-weight: bold;
text-align: center;
position: absolute;
}
.progress .progress-value.red {
color: #f74d4d;
}
.progress .progress-value.dark-yellow {
color: #f78c4d;
}
.progress .progress-value.yellow {
color: #f7f24d;
}
.progress .progress-value.green {
color: #28b779;
}
.progress.red .progress-bar{
border-color: #f74d4d;
}
.progress.red .progress-left .progress-bar{
animation: loading-2 1.5s linear forwards 1.8s;
}
.progress.dark-yellow .progress-bar{
border-color: #f78c4d;
}
.progress.dark-yellow .progress-left .progress-bar{
animation: loading-4 0.4s linear forwards 1.8s;
}
.progress.yellow .progress-bar{
border-color:#f7f24d;
}
.progress.yellow .progress-left .progress-bar{
animation: loading-3 1s linear forwards 1.8s;
}
.progress.green .progress-bar{
border-color: #28b779;
}
.progress.green .progress-left .progress-bar{
animation: loading-5 1.2s linear forwards 1.8s;
}
.progress > span {
background-color: none;
}
#keyframes loading-1{
0%{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100%{
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
}
#keyframes loading-2{
0%{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100%{
-webkit-transform: rotate(144deg);
transform: rotate(144deg);
}
}
#keyframes loading-3{
0%{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100%{
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
}
#keyframes loading-4{
0%{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100%{
-webkit-transform: rotate(36deg);
transform: rotate(36deg);
}
}
#keyframes loading-5{
0%{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100%{
-webkit-transform: rotate(126deg);
transform: rotate(126deg);
}
}
#media only screen and (max-width: 990px){
.progress{ margin-bottom: 20px; }
}
<div class="component-progress-info">
<div class="component-progress">
<div class="progress <?php echo $componentclass; ?>">
<span class="progress-left">
<span class="progress-bar"></span>
</span>
<span class="progress-right">
<span class="progress-bar"></span>
</span>
<div class="progress-value red">5%</div>
</div>
</div>
<div class="component-info">
</div>
</div>
I have html inside a for-loop. But it is resulting me different response
Looking at the CSS (just the relevant parts):
.progress.red .progress-left .progress-bar{
animation: loading-2 1.5s linear forwards 1.8s;
}
.progress.dark-yellow .progress-left .progress-bar{
animation: loading-4 0.4s linear forwards 1.8s;
}
.progress.yellow .progress-left .progress-bar{
animation: loading-3 1s linear forwards 1.8s;
}
.progress.green .progress-left .progress-bar{
animation: loading-5 1.2s linear forwards 1.8s;
}
Different colors are set to use different keyframes, for example loading-3 for yellow, loading-5 for green, as seen above.
The keyframes then are defined with different rotations. Looking at two of them as an example:
#keyframes loading-2{
0%{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100%{
-webkit-transform: rotate(144deg);
transform: rotate(144deg);
}
}
#keyframes loading-3{
0%{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100%{
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
}
Here loading-2 transforms from 0deg to 144deg.
Below loading-3 transforms from 0deg to 90deg.
Should the keyframes not be the same for every progress bar? Only the background color should change. But you define different keyframes for different colors, which is probably the cause if not part of it.

Can't animate a card opening

I am trying to animate a frame where the 'heart-flap' opens to the left. But can't seem to do it -- the axis of the box and the heart is not the same while opening.
My jsFiddle https://jsfiddle.net/dk1446/unjqx08d/2/
#import url(https://fonts.googleapis.com/css?family=Poiret+One);
body {
background-color: white;
font-family: 'Poiret One', Segoe UI Light, cursive;
}
.heart {
background-color: #d32f2f;
display: inline-block;
height: 200px;
margin: 0 10px;
position: relative;
top: 0;
/* transform: rotate(-45deg); */
width: 200px;
margin-top: 200px;
margin-left: 500px;
/* transform: rotate(0deg); */
}
.heart:before,
.heart:after {
content: "";
background-color: #d32f2f;
border-radius: 50%;
height: 200px;
position: absolute;
width: 200px;
}
.heart:before {
top: -110px;
left: 0;
}
.heart:after {
left: 110px;
top: 0;
}
#card {
margin-top: 200px;
}
#message {
height: 400px;
width: 400px;
margin-top: -410px;
margin-left: 500px;
background-color: #333;
color: white;
border: 3px dashed violet;
border-radius: 35% 0 35% 0;
}
#card #heart1 {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
-webkit-animation: closeLeft 2s ease-in-out forwards;
-moz-animation: closeLeft 2s ease-in-out forwards;
-ms-animation: closeLeft 2s ease-in-out forwards;
animation: closeLeft 2s ease-in-out forwards;
}
#card:hover #heart1 {
-webkit-animation: openLeft 2s ease-in-out forwards;
-moz-animation: openLeft 2s ease-in-out forwards;
-ms-animation: openLeft 2 ease-in-out forwards;
animation: openLeft 2s ease-in-out forwards;
}
#-webkit-keyframes closeLeft {
from {
-webkit-transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(180deg);
}
}
#-moz-keyframes closeLeft {
from {
-moz-transform: rotateY(0deg);
}
to {
-moz-transform: rotateY(180deg);
}
}
#-ms-keyframes closeLeft {
from {
-ms-transform: rotateY(0deg);
}
to {
-ms-transform: rotateY(180deg);
}
}
#keyframes closeLeft {
from {
transform: rotateY(0deg);
}
to {
transform: rotateY(180deg);
}
}
#-moz-keyframes openLeft {
from {
-moz-transform: rotateY(180deg);
}
to {
-moz-transform: rotateY(0deg);
}
}
#-webkit-keyframes openLeft {
from {
-webkit-transform: rotateY(180deg);
}
to {
-webkit-transform: rotateY(0deg);
}
}
#-ms-keyframes openLeft {
from {
-ms-transform: rotateY(180deg);
}
to {
-ms-transform: rotateY(0deg);
}
}
#keyframes openLeft {
from {
transform: rotateY(180deg);
}
to {
transform: rotateY(0deg);
}
}
<div id="card">
<div class="heart" id="heart1"></div>
<div id="message">
<h2>Happy Valentines Day</h2>
</div>
<!-- <div class="heart" id="heart2"></div> -->
</div>
I would like the 'heart' to open to the left and close right. It should be in line with the box underneath. I can't seem to figure out a way.
You almost had it! You need to add transform-origin: 0 0 to the #heart1
#import url(https://fonts.googleapis.com/css?family=Poiret+One);
body {
background-color: white;
font-family: 'Poiret One', Segoe UI Light, cursive;
}
.heart {
background-color: #d32f2f;
display: inline-block;
height: 200px;
margin: 0 10px;
position: relative;
top: 0;
/* transform: rotate(-45deg); */
width: 200px;
margin-top: 200px;
margin-left: 500px;
/* transform: rotate(0deg); */
}
.heart:before,
.heart:after {
content: "";
background-color: #d32f2f;
border-radius: 50%;
height: 200px;
position: absolute;
width: 200px;
}
.heart:before {
top: -110px;
left: 0;
}
.heart:after {
left: 110px;
top: 0;
}
#card {
margin-top: 200px;
}
#message {
height: 400px;
width: 400px;
margin-top: -410px;
margin-left: 500px;
background-color: #333;
color: white;
border: 3px dashed violet;
border-radius: 35% 0 35% 0;
}
#card #heart1 {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
-webkit-animation: closeLeft 2s ease-in-out forwards;
-moz-animation: closeLeft 2s ease-in-out forwards;
-ms-animation: closeLeft 2s ease-in-out forwards;
animation: closeLeft 2s ease-in-out forwards;
transform-origin: 0 0;
}
#card:hover #heart1 {
-webkit-animation: openLeft 2s ease-in-out forwards;
-moz-animation: openLeft 2s ease-in-out forwards;
-ms-animation: openLeft 2 ease-in-out forwards;
animation: openLeft 2s ease-in-out forwards;
}
#-webkit-keyframes closeLeft {
from {
-webkit-transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(180deg);
}
}
#-moz-keyframes closeLeft {
from {
-moz-transform: rotateY(0deg);
}
to {
-moz-transform: rotateY(180deg);
}
}
#-ms-keyframes closeLeft {
from {
-ms-transform: rotateY(0deg);
}
to {
-ms-transform: rotateY(180deg);
}
}
#keyframes closeLeft {
from {
transform: rotateY(0deg);
}
to {
transform: rotateY(180deg);
}
}
#-moz-keyframes openLeft {
from {
-moz-transform: rotateY(180deg);
}
to {
-moz-transform: rotateY(0deg);
}
}
#-webkit-keyframes openLeft {
from {
-webkit-transform: rotateY(180deg);
}
to {
-webkit-transform: rotateY(0deg);
}
}
#-ms-keyframes openLeft {
from {
-ms-transform: rotateY(180deg);
}
to {
-ms-transform: rotateY(0deg);
}
}
#keyframes openLeft {
from {
transform: rotateY(180deg);
}
to {
transform: rotateY(0deg);
}
}
<div id="card">
<div class="heart" id="heart1"></div>
<div id="message">
<h2>Happy Valentines Day</h2>
</div>
<!-- <div class="heart" id="heart2"></div> -->
</div>
Here's the fiddle: https://jsfiddle.net/disinfor/y0p2t94q/1/
Edit for more info: the default origin for an element is 50% 50% 0 - which translates to the middle of the element. 0 0 moves the point of origin to the top left corner.
More reading: https://www.w3schools.com/cssref/css3_pr_transform-origin.asp
#rorschach: finally you got the animation, but did you notice your card area yet it's not sorted out!! when you hover on the card the animation should start I guess, so I think either you set max-width to the card.

CSS3 animation - two issues

Here are some issues which I can't seem to figure out.
When you hover on the image I am animating a few styles but as you will see, when the border size increases, everything else moves with it.
When you change the sidetext to something longer or shorter, it decides to move positions.
Please can someone explain what I am doing wrong?
/*
Colors:
#FF0F00 = red
#FFFF04 = yellow
#387F23 = green
*/
* {
box-sizing: border-box;
}
body {
margin: 0;
background-color: yellow;
font-family: Arial, Helvetica, sans-serif;
}
.animate {
animation-fill-mode: forwards;
animation-duration: 1s;
}
.one {
-webkit-animation-delay: 0.4s;
-moz-animation-delay: 0.4s;
animation-delay: 0.4s;
}
.two {
-webkit-animation-delay: 1.7s;
-moz-animation-delay: 1.7s;
animation-delay: 1.7s;
}
.three {
-webkit-animation-delay: 2.3s;
-moz-animation-delay: 2.3s;
animation-delay: 2.3s;
}
.four {
-webkit-animation-delay: 3.3s;
-moz-animation-delay: 3.3s;
animation-delay: 3.3s;
}
#keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.fadeIn {
-webkit-animation-name: fadeIn;
animation-name: fadeIn;
}
#keyframes fadeInDown {
from {
opacity: 0;
-webkit-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
to {
opacity: 1;
-webkit-transform: none;
transform: none;
}
}
.fadeInDown {
-webkit-animation-name: fadeInDown;
animation-name: fadeInDown;
}
#keyframes fadeInLeft {
from {
opacity: 0;
-webkit-transform: translate3d(-100%, 0, 0);
transform: translate3d(-100%, 0, 0);
}
to {
opacity: 1;
-webkit-transform: none;
transform: none;
}
}
.fadeInLeft {
-webkit-animation-name: fadeInLeft;
animation-name: fadeInLeft;
}
/* FADE IN RIGHT */
#-webkit-keyframes fadeInRight {
from {
opacity: 0;
-webkit-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0);
}
to {
opacity: 1;
-webkit-transform: none;
transform: none;
}
}
#keyframes fadeInRight {
from {
opacity: 0;
-webkit-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0);
}
to {
opacity: 1;
-webkit-transform: none;
transform: none;
}
}
.fadeInRight {
-webkit-animation-name: fadeInRight;
animation-name: fadeInRight;
}
.container {
margin-left: auto;
margin-right: auto;
width: 100%;
}
.hero__img img {
max-width: 100%;
vertical-align: middle;
}
.hero__center:after {
position: absolute;
content: " ";
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: red;
/* z-index: -1; */
opacity: 0;
transition: opacity 0.4s ease-in;
}
#media (min-width: 920px) {
.hero {
margin: 0 auto;
width: 700px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
opacity: 0;
}
.hero__heading {
position: absolute;
font-size: 80px;
color: #0004f3;
text-transform: uppercase;
font-weight: bold;
font-kerning: -3px;
letter-spacing: 4px;
z-index: 1;
}
.hero__heading--top {
left: -85px;
top: -150px;
opacity: 1;
}
.hero__heading--bottom {
right: -85px;
bottom: -150px;
opacity: 1;
}
.hero__center {
position: relative;
border: 5px solid blue;
transition: border 0.4s ease-in;
}
.hero__center:hover {
border: 10px solid #387F23;
transition: border 0.4s ease-in;
}
.hero__center:hover:after {
opacity: 0.4;
transition: opacity 0.4s ease-in;
}
.hero__center:hover .hero__sideText {
color: red;
transition: color 0.4s ease-in;
}
.hero__img img {
opacity: 1;
transition: opacity 0.4s ease-in;
}
/* .hero__img:hover img {
opacity: 0.4;
transition: opacity 0.4s ease-in;
} */
/* .hero__center:hover {
border: 5px solid green;
transition: border 0.5s;
} */
.hero__sideText {
position: absolute;
top: 50%;
color: #0004f3;
transition: color 0.4s ease-in;
}
.hero__side--left {
left: -50px;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
transform-origin: center center;
}
.hero__side--right {
right: -50px;
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-o-transform: rotate(270deg);
transform: rotate(270deg);
transform-origin: center center;
}
}
<div class="container">
<div class="hero animate fadeIn one">
<div class="hero__center">
<span class="hero__heading hero__heading--top animate fadeInLeft one">Lorem</span>
<span class="hero__heading hero__heading--bottom animate fadeInRight one">Ipsum</span>
<div class="hero__img">
<img src="http://via.placeholder.com/980x550" alt="">
</div>
<span class="hero__sideText hero__side--left">Side text</span>
<span class="hero__sideText hero__side--right">Side text</span>
</div>
</div>
</div>
Since the size of your box changes by changing the border width, the elements change their position aswell.
try adding :
.hero__center:hover {
margin:-5px;
}
to work against the border change.
2.
The transform rotation uses the center point of your element as its origin (transform-origin: center center;). When increasing the characters you increase the width so the point which the rotation choses as its origin shifts aswell.
To change that you have to fix that point to a specific location. Try adding a div wrappers around your sideText spans with the following css:
.wrapper-left {
position:relative;
left: -50%;
}
.wrapper-right {
position:relative;
left: 50%;
}

Rotate transform not working in a media query

I have a rotate animation that I am symbolizing that something is loading. This works great (except it doesn't rotate continuously, it kind of stops some when it has went around 360 degrees), but on some phones (I have an android note 4) it doesn't spin at all. Then on others (iphones) my circle actually rotates like it is swinging or it is fixed at one corner of the circle and it spins from that axis.
I have webkits in my code and I have the img set to this:
#spinning-circle img {
width: 100%;
height: auto;
}
Why would my image be doing these things. I can give the web url to see this live if you want to see it in a mobile setting.
#spinning-circle-container {
float: left;
width: 40%;
background: red;
padding: 140px 0 0 10%;
}
#spinning-circle {
animation-name: spinning-circle;
animation-duration: 4s;
animation-iteration-count: infinite;
width: 100px;
height: 100px;
}
#spinning-circle img {
width: 100%;
height: auto;
}
#-webkit-keyframes spinning-circle {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#spinning-circle-title {
padding-top: 35px;
color: #000;
font-size: 2.8em;
}
#media screen and (max-width:640px) {
#spinning-circle-container {
width: 80%;
padding: 40px 0 0 6%;
}
#spinning-circle {
animation-name: spinning-circle;
animation-duration: 4s;
animation-iteration-count: infinite;
width: 50px;
height: 50px;
}
#spinning-circle img {
width: 100%;
height: auto;
}
#-webkit-keyframes spinning-circle {
0% {
-webkit-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
}
}
#spinning-circle-title {
padding-top: 35px;
color: blue;
font-size: 1.5em;
}
}
<div id="spinning-circle-container">
<div id="spinning-circle">
<img src="http://optimumwebdesigns.com/images/spinning-circle.png">
</div>
<div id="spinning-circle-title">LOADING...</div>
</div>
You need to use prefixed -webkit-transform in prefixed #webkit-keyframes and not-prefixed transform in not-prefixed #keyframes. And also you need to add prefixed -webkit-animation.
If you want animation doesn't stop at the end, you could use animation-timing-function: linear, but then animation'll have a constant speed.
You don't need to duplicate #keyframes and other properties inside #media screen {}.
#spinning-circle-container {
float: left;
width: 40%;
background: red;
padding: 140px 0 0 10%;
}
#spinning-circle {
-webkit-animation: spinning-circle linear 2s infinite;
animation: spinning-circle linear 2s infinite;
width: 100px;
height: 100px;
}
#spinning-circle img {
width: 100%;
height: auto;
}
#spinning-circle-title {
padding-top: 35px;
color: #000;
font-size: 2.8em;
}
#media screen and (max-width: 640px) {
#spinning-circle-container {
width: 80%;
padding: 40px 0 0 6%;
}
#spinning-circle {
width: 50px;
height: 50px;
}
#spinning-circle-title {
color: blue;
font-size: 1.5em;
}
}
#-webkit-keyframes spinning-circle {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
#keyframes spinning-circle {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div id="spinning-circle-container">
<div id="spinning-circle">
<img src="http://optimumwebdesigns.com/images/spinning-circle.png">
</div>
<div id="spinning-circle-title">LOADING...</div>
</div>
You have to add animation-timing-function: linear; in your animation definition.
Here you have a code working https://jsfiddle.net/xhurpqLd/
-- EDIT --
You also have
#-webkit-keyframes spinning-circle {
0% {
-webkit-transform: rotate(0deg) ;
-webkit-transform: rotate(0deg) ;
}
100% {
-webkit-transform: rotate(360deg) ;
-webkit-transform: rotate(360deg) ;
}
}
You only define the transform for webkit. Change to
#-webkit-keyframes spinning-circle {
0% {
-webkit-transform: rotate(0deg) ;
transform: rotate(0deg) ;
}
100% {
-webkit-transform: rotate(360deg) ;
transform: rotate(360deg) ;
}
}
Here you have the updated code https://jsfiddle.net/xhurpqLd/3/. It works on my Android.
You can also add -ms-transform for IE support.
Lines 731-733 and 1391-1393 of main-style.css appear to be causing the swinging problem.
*::after, *::before {
content: '';
}
should be
*::after, *::before {
content: '';
display: table;
}
assuming you're trying to use this clearfix method

Making a CSS3 animation more reliable among browsers

I have this CSS3 animation working on codepen.
HTML
<div class="heart heart1"></div>
<div class="heart heart2"></div>
CSS3
html, body{
width: 100%;
height: 100%;
min-width: 500px;
min-height: 500px;
overflow: hidden;
}
.heart {
position: absolute;
width: 100px;
height: 90px;
top: 50%;
left: 50%;
margin-top: -45px;
margin-left: -50px;
}
.heart:before,
.heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #fc2e5a;
border-radius: 50px 50px 0 0;
transform: rotate(-45deg);
transform-origin: 0 100%;
}
.heart:after {
left: 0;
transform: rotate(45deg);
transform-origin :100% 100%;
}
.heart1{
animation: heart-anim 1s linear .4s infinite;
}
.heart2{
animation: pounding .5s linear infinite alternate;
}
.heart1:after, .heart1:before{
background-color: #ff7693;
}
#keyframes pounding{
0%{ transform: scale(1.5); }
100%{ transform: scale(1); }
}
#keyframes heart-anim {
46% {
transform: scale(1);
}
50% {
transform: scale(1.3);
}
52% {
transform: scale(1.5);
}
55% {
transform: scale(3);
}
100% {
opacity: 0;
transform: scale(50);
}
}
Check it here: http://codepen.io/RadValentin/pen/sfnCE
As you can see is working ok, BUT, if I post the exact code to my local server OR to jsfiddle it does not work any more: http://jsfiddle.net/40aydbfr/
I believe the animation is not made according to the best practices since it breaks very easily.
So, Why it does not work outside of codepen and how can I make it more cross browser compatible.
PS: Im using Chrome.
It doesn't work because you are missing vendor prefixes for -webkit- browsers.
The reason why it works on codepen is because, if you click on the settings button above the CSS window, you'll see that -prefix-free is enabled, which means it adds the prefixes automatically.
Always check browser support, if something doesn't work.
Updated Codepen
Updated Fiddle
html,
body {
width: 100%;
height: 100%;
min-width: 500px;
min-height: 500px;
overflow: hidden;
}
.heart {
position: absolute;
width: 100px;
height: 90px;
top: 50%;
left: 50%;
margin-top: -45px;
margin-left: -50px;
}
.heart:before,
.heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #fc2e5a;
border-radius: 50px 50px 0 0;
transform: rotate(-45deg);
transform-origin: 0 100%;
}
.heart:after {
left: 0;
transform: rotate(45deg);
transform-origin: 100% 100%;
}
.heart1 {
-webkit-animation: heart-anim 1s linear .4s infinite;
animation: heart-anim 1s linear .4s infinite;
}
.heart2 {
-webkit-animation: pounding .5s linear infinite alternate;
animation: pounding .5s linear infinite alternate;
}
.heart1:after,
.heart1:before {
background-color: #ff7693;
}
#-webkit-keyframes pounding {
0% {
transform: scale(1.5);
}
100% {
transform: scale(1);
}
}
#keyframes pounding {
0% {
transform: scale(1.5);
}
100% {
transform: scale(1);
}
}
#-webkit-keyframes heart-anim {
46% {
transform: scale(1);
}
50% {
transform: scale(1.3);
}
52% {
transform: scale(1.5);
}
55% {
transform: scale(3);
}
100% {
opacity: 0;
transform: scale(50);
}
}
#keyframes heart-anim {
46% {
transform: scale(1);
}
50% {
transform: scale(1.3);
}
52% {
transform: scale(1.5);
}
55% {
transform: scale(3);
}
100% {
opacity: 0;
transform: scale(50);
}
}
<div class="heart heart1"></div>
<div class="heart heart2"></div>