math in SCSS mixin as part of for loop - css

I have a for loop that I am sending into a mixin, but I want to subtract 1 from the count when I am actually doing the math in the -webkit-transform: rotate(($number*30)deg); I keep getting invalid css errors.
#mixin rotate($count){
$number: #{$count}{-1};
.sk-circle#{$count} {
-webkit-transform: rotate(($number*30)deg);
-ms-transform: rotate(30deg);
transform: rotate(30deg);
}
}
#for $i from 2 through 12{
#include rotate($i)
}

A few issues in the code:
Remove the # from the $number definition.
You can multiply $number by Xdeg and it will add the units
Here's the updated version:
#mixin rotate($count){
$number: $count - 1;
.sk-circle#{$count} {
-webkit-transform: rotate($number*30deg);
-ms-transform: rotate($number*30deg);
transform: rotate($number*30deg);
}
}
#for $i from 2 through 12{
#include rotate($i)
}
compiles to:
.sk-circle2 {
-webkit-transform: rotate(30deg);
-ms-transform: rotate(30deg);
transform: rotate(30deg);
}
.sk-circle3 {
-webkit-transform: rotate(60deg);
-ms-transform: rotate(60deg);
transform: rotate(60deg);
}
.sk-circle4 {
-webkit-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
.sk-circle5 {
-webkit-transform: rotate(120deg);
-ms-transform: rotate(120deg);
transform: rotate(120deg);
}
.sk-circle6 {
-webkit-transform: rotate(150deg);
-ms-transform: rotate(150deg);
transform: rotate(150deg);
}
.sk-circle7 {
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
.sk-circle8 {
-webkit-transform: rotate(210deg);
-ms-transform: rotate(210deg);
transform: rotate(210deg);
}
.sk-circle9 {
-webkit-transform: rotate(240deg);
-ms-transform: rotate(240deg);
transform: rotate(240deg);
}
.sk-circle10 {
-webkit-transform: rotate(270deg);
-ms-transform: rotate(270deg);
transform: rotate(270deg);
}
.sk-circle11 {
-webkit-transform: rotate(300deg);
-ms-transform: rotate(300deg);
transform: rotate(300deg);
}
.sk-circle12 {
-webkit-transform: rotate(330deg);
-ms-transform: rotate(330deg);
transform: rotate(330deg);
}

Related

How to reduce animate.css heartbeat enlarge size

So I am using animate.css to animate a keyboard that shows what key to input. Currently I'm using animate__heartbeat to animate the keys to be pressed but the problem is the animation makes it overflow other keys and I would like to reduce that size.
These are the classes I am using on each keys:
class="animate__animated animate__slow animate__infinite animate__heartBeat"
Since I am new to animate.css I dont know how to change the size it increases during the animation and is there a way to reduce it in css?
if you are using the animate.min.css go to this link https://unminify.com/ and unminify the css and find the below code:
#-webkit-keyframes heartBeat {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
14% {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
28% {
-webkit-transform: scale(1);
transform: scale(1);
}
42% {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
70% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
#keyframes heartBeat {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
14% {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
28% {
-webkit-transform: scale(1);
transform: scale(1);
}
42% {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
70% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
and Replace them with:
#-webkit-keyframes heartBeat {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
14% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
28% {
-webkit-transform: scale(1);
transform: scale(1);
}
42% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
70% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
#keyframes heartBeat {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
14% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
28% {
-webkit-transform: scale(1);
transform: scale(1);
}
42% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
70% {
-webkit-transform: scale(1);
transform: scale(1);
}
}

z-index not working properly on ios devices

I am working on a preloader animation on other devices everything is working fine except the ios browser...
initially, the polaroid image should be at the back first, (it should look like it was printing a polaroid image from the camera), after that it flips then positions on top of the camera then scales to 0 for the outro of the polaroid.
here is the codepen codes
.preloader {
background: #f8f8f8;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.stack,
.cameras {
position: absolute;
top: 50%;
left: 50%;
-moz-transform: translateX(-50%) translateY(-20%);
-webkit-transform: translateX(-50%) translateY(-20%);
-o-transform: translateX(-50%) translateY(-20%);
-ms-transform: translateX(-50%) translateY(-20%);
transform: translateX(-50%) translateY(-20%);
}
.cameras {
-webkit-perspective: 800px;
perspective: 800px;
-moz-transform: translateX(-50%) translateY(-85%);
-webkit-transform: translateX(-50%) translateY(-85%);
-o-transform: translateX(-50%) translateY(-85%);
-ms-transform: translateX(-50%) translateY(-85%);
transform: translateX(-50%) translateY(-85%);
}
.preloader .cameras span img.camera-img {
width: 100%;
position: relative;
z-index: 9;
}
.cameras span {
display: inline-block;
position: relative;
}
.cameras span .polaroid {
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
max-width: 130px;
position: absolute;
z-index: 0;
left: 0;
right: 0;
top: 0;
margin: auto;
-webkit-transition: all 2s linear;
-moz-transition: all 2s linear;
-ms-transition: all 2s linear;
-o-transition: all 2s linear;
transition: all 2s linear;
animation: ikot infinite 5s linear;
}
#keyframes ikot {
0% {
bottom: 0;
z-index: 0;
}
60% {
bottom: 150%;
z-index: 0;
-webkit-transform: rotateX(0deg) translateZ(2px);
-ms-transform: rotateX(0deg) translateZ(2px);
-o-transform: rotateX(0deg) translateZ(2px);
transform: rotateX(0deg) translateZ(2px);
}
66% {
bottom: 180%;
z-index: 0;
-webkit-transform: rotateX(90deg) translateZ(2px);
-ms-transform: rotateX(90deg) translateZ(2px);
-o-transform: rotateX(90deg) translateZ(2px);
transform: rotateX(90deg) translateZ(2px);
}
68% {
bottom: 30%;
z-index: 0;
-webkit-transform: rotateX(180deg) translateZ(2px);
-ms-transform: rotateX(180deg) translateZ(2px);
-o-transform: rotateX(180deg) translateZ(2px);
transform: rotateX(180deg) translateZ(2px);
}
75% {
bottom: 0%;
z-index: 0;
-webkit-transform: rotateX(-80deg) translateZ(2px);
-ms-transform: rotateX(-80deg) translateZ(2px);
-o-transform: rotateX(-80deg) translateZ(2px);
transform: rotateX(-80deg) translateZ(2px);
}
80% {
bottom: -150%;
z-index: 0;
-webkit-transform: rotateX(-140deg) translateZ(2px);
-ms-transform: rotateX(-140deg) translateZ(2px);
-o-transform: rotateX(-140deg) translateZ(2px);
transform: rotateX(-140deg) translateZ(2px);
}
82% {
bottom: -120%;
z-index: 99;
-webkit-transform: rotateX(-75deg) translateZ(2px);
-ms-transform: rotateX(-75deg) translateZ(2px);
-o-transform: rotateX(-75deg) translateZ(2px);
transform: rotateX(-75deg) translateZ(2px);
}
86% {
bottom: -55%;
z-index: 99;
-webkit-transform: rotateX(-40deg) translateZ(2px);
-ms-transform: rotateX(-40deg) translateZ(2px);
-o-transform: rotateX(-40deg) translateZ(2px);
transform: rotateX(-40deg) translateZ(2px);
}
90% {
bottom: 0;
z-index: 99;
-webkit-transform: rotateX(0) translateZ(2px) scale(1.8);
-ms-transform: rotateX(0) translateZ(2px) scale(1.8);
-o-transform: rotateX(0) translateZ(2px) scale(1.8);
transform: rotateX(0) translateZ(2px) scale(1.8);
}
95% {
bottom: 0;
z-index: 1;
-webkit-transform: scale(1.8);
-ms-transform: scale(1.8);
-o-transform: scale(1.8);
transform: scale(1.8);
}
100% {
-moz-transform: scale(0);
-webkit-transform: scale(0);
-o-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
}
}
#-webkit-keyframes ikot {
0% {
bottom: 0;
z-index: 0;
}
60% {
bottom: 150%;
z-index: 0;
-webkit-transform: rotateX(0deg) translateZ(2px);
-ms-transform: rotateX(0deg) translateZ(2px);
-o-transform: rotateX(0deg) translateZ(2px);
transform: rotateX(0deg) translateZ(2px);
}
66% {
bottom: 180%;
z-index: 0;
-webkit-transform: rotateX(90deg) translateZ(2px);
-ms-transform: rotateX(90deg) translateZ(2px);
-o-transform: rotateX(90deg) translateZ(2px);
transform: rotateX(90deg) translateZ(2px);
}
68% {
bottom: 30%;
z-index: 0;
-webkit-transform: rotateX(180deg) translateZ(2px);
-ms-transform: rotateX(180deg) translateZ(2px);
-o-transform: rotateX(180deg) translateZ(2px);
transform: rotateX(180deg) translateZ(2px);
}
75% {
bottom: 0%;
z-index: 0;
-webkit-transform: rotateX(-80deg) translateZ(2px);
-ms-transform: rotateX(-80deg) translateZ(2px);
-o-transform: rotateX(-80deg) translateZ(2px);
transform: rotateX(-80deg) translateZ(2px);
}
80% {
bottom: -150%;
z-index: 0;
-webkit-transform: rotateX(-140deg) translateZ(2px);
-ms-transform: rotateX(-140deg) translateZ(2px);
-o-transform: rotateX(-140deg) translateZ(2px);
transform: rotateX(-140deg) translateZ(2px);
}
82% {
bottom: -120%;
z-index: 99;
-webkit-transform: rotateX(-75deg) translateZ(2px);
-ms-transform: rotateX(-75deg) translateZ(2px);
-o-transform: rotateX(-75deg) translateZ(2px);
transform: rotateX(-75deg) translateZ(2px);
}
86% {
bottom: -55%;
z-index: 99;
-webkit-transform: rotateX(-40deg) translateZ(2px);
-ms-transform: rotateX(-40deg) translateZ(2px);
-o-transform: rotateX(-40deg) translateZ(2px);
transform: rotateX(-40deg) translateZ(2px);
}
90% {
bottom: 0;
z-index: 99;
-webkit-transform: rotateX(0) translateZ(2px) scale(1.8);
-ms-transform: rotateX(0) translateZ(2px) scale(1.8);
-o-transform: rotateX(0) translateZ(2px) scale(1.8);
transform: rotateX(0) translateZ(2px) scale(1.8);
}
95% {
bottom: 0;
z-index: 1;
-webkit-transform: scale(1.8);
-ms-transform: scale(1.8);
-o-transform: scale(1.8);
transform: scale(1.8);
}
100% {
-moz-transform: scale(0);
-webkit-transform: scale(0);
-o-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
}
}
#-moz-keyframes ikot {
0% {
bottom: 0;
z-index: 0;
}
60% {
bottom: 150%;
z-index: 0;
-webkit-transform: rotateX(0deg) translateZ(2px);
-ms-transform: rotateX(0deg) translateZ(2px);
-o-transform: rotateX(0deg) translateZ(2px);
transform: rotateX(0deg) translateZ(2px);
}
66% {
bottom: 180%;
z-index: 0;
-webkit-transform: rotateX(90deg) translateZ(2px);
-ms-transform: rotateX(90deg) translateZ(2px);
-o-transform: rotateX(90deg) translateZ(2px);
transform: rotateX(90deg) translateZ(2px);
}
68% {
bottom: 30%;
z-index: 0;
-webkit-transform: rotateX(180deg) translateZ(2px);
-ms-transform: rotateX(180deg) translateZ(2px);
-o-transform: rotateX(180deg) translateZ(2px);
transform: rotateX(180deg) translateZ(2px);
}
75% {
bottom: 0%;
z-index: 0;
-webkit-transform: rotateX(-80deg) translateZ(2px);
-ms-transform: rotateX(-80deg) translateZ(2px);
-o-transform: rotateX(-80deg) translateZ(2px);
transform: rotateX(-80deg) translateZ(2px);
}
80% {
bottom: -150%;
z-index: 0;
-webkit-transform: rotateX(-140deg) translateZ(2px);
-ms-transform: rotateX(-140deg) translateZ(2px);
-o-transform: rotateX(-140deg) translateZ(2px);
transform: rotateX(-140deg) translateZ(2px);
}
82% {
bottom: -120%;
z-index: 99;
-webkit-transform: rotateX(-75deg) translateZ(2px);
-ms-transform: rotateX(-75deg) translateZ(2px);
-o-transform: rotateX(-75deg) translateZ(2px);
transform: rotateX(-75deg) translateZ(2px);
}
86% {
bottom: -55%;
z-index: 99;
-webkit-transform: rotateX(-40deg) translateZ(2px);
-ms-transform: rotateX(-40deg) translateZ(2px);
-o-transform: rotateX(-40deg) translateZ(2px);
transform: rotateX(-40deg) translateZ(2px);
}
90% {
bottom: 0;
z-index: 99;
-webkit-transform: rotateX(0) translateZ(2px) scale(1.8);
-ms-transform: rotateX(0) translateZ(2px) scale(1.8);
-o-transform: rotateX(0) translateZ(2px) scale(1.8);
transform: rotateX(0) translateZ(2px) scale(1.8);
}
95% {
bottom: 0;
z-index: 1;
-webkit-transform: scale(1.8);
-ms-transform: scale(1.8);
-o-transform: scale(1.8);
transform: scale(1.8);
}
100% {
-moz-transform: scale(0);
-webkit-transform: scale(0);
-o-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
}
}
#-ms-keyframes ikot {
0% {
bottom: 0;
z-index: 0;
}
60% {
bottom: 150%;
z-index: 0;
-webkit-transform: rotateX(0deg) translateZ(2px);
-ms-transform: rotateX(0deg) translateZ(2px);
-o-transform: rotateX(0deg) translateZ(2px);
transform: rotateX(0deg) translateZ(2px);
}
66% {
bottom: 180%;
z-index: 0;
-webkit-transform: rotateX(90deg) translateZ(2px);
-ms-transform: rotateX(90deg) translateZ(2px);
-o-transform: rotateX(90deg) translateZ(2px);
transform: rotateX(90deg) translateZ(2px);
}
68% {
bottom: 30%;
z-index: 0;
-webkit-transform: rotateX(180deg) translateZ(2px);
-ms-transform: rotateX(180deg) translateZ(2px);
-o-transform: rotateX(180deg) translateZ(2px);
transform: rotateX(180deg) translateZ(2px);
}
75% {
bottom: 0%;
z-index: 0;
-webkit-transform: rotateX(-80deg) translateZ(2px);
-ms-transform: rotateX(-80deg) translateZ(2px);
-o-transform: rotateX(-80deg) translateZ(2px);
transform: rotateX(-80deg) translateZ(2px);
}
80% {
bottom: -150%;
z-index: 0;
-webkit-transform: rotateX(-140deg) translateZ(2px);
-ms-transform: rotateX(-140deg) translateZ(2px);
-o-transform: rotateX(-140deg) translateZ(2px);
transform: rotateX(-140deg) translateZ(2px);
}
82% {
bottom: -120%;
z-index: 99;
-webkit-transform: rotateX(-75deg) translateZ(2px);
-ms-transform: rotateX(-75deg) translateZ(2px);
-o-transform: rotateX(-75deg) translateZ(2px);
transform: rotateX(-75deg) translateZ(2px);
}
86% {
bottom: -55%;
z-index: 99;
-webkit-transform: rotateX(-40deg) translateZ(2px);
-ms-transform: rotateX(-40deg) translateZ(2px);
-o-transform: rotateX(-40deg) translateZ(2px);
transform: rotateX(-40deg) translateZ(2px);
}
90% {
bottom: 0;
z-index: 99;
-webkit-transform: rotateX(0) translateZ(2px) scale(1.8);
-ms-transform: rotateX(0) translateZ(2px) scale(1.8);
-o-transform: rotateX(0) translateZ(2px) scale(1.8);
transform: rotateX(0) translateZ(2px) scale(1.8);
}
95% {
bottom: 0;
z-index: 1;
-webkit-transform: scale(1.8);
-ms-transform: scale(1.8);
-o-transform: scale(1.8);
transform: scale(1.8);
}
100% {
-moz-transform: scale(0);
-webkit-transform: scale(0);
-o-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
}
}
#-o-keyframes ikot {
0% {
bottom: 0;
z-index: 0;
}
60% {
bottom: 150%;
z-index: 0;
-webkit-transform: rotateX(0deg) translateZ(2px);
-ms-transform: rotateX(0deg) translateZ(2px);
-o-transform: rotateX(0deg) translateZ(2px);
transform: rotateX(0deg) translateZ(2px);
}
66% {
bottom: 180%;
z-index: 0;
-webkit-transform: rotateX(90deg) translateZ(2px);
-ms-transform: rotateX(90deg) translateZ(2px);
-o-transform: rotateX(90deg) translateZ(2px);
transform: rotateX(90deg) translateZ(2px);
}
68% {
bottom: 30%;
z-index: 0;
-webkit-transform: rotateX(180deg) translateZ(2px);
-ms-transform: rotateX(180deg) translateZ(2px);
-o-transform: rotateX(180deg) translateZ(2px);
transform: rotateX(180deg) translateZ(2px);
}
75% {
bottom: 0%;
z-index: 0;
-webkit-transform: rotateX(-80deg) translateZ(2px);
-ms-transform: rotateX(-80deg) translateZ(2px);
-o-transform: rotateX(-80deg) translateZ(2px);
transform: rotateX(-80deg) translateZ(2px);
}
80% {
bottom: -150%;
z-index: 0;
-webkit-transform: rotateX(-140deg) translateZ(2px);
-ms-transform: rotateX(-140deg) translateZ(2px);
-o-transform: rotateX(-140deg) translateZ(2px);
transform: rotateX(-140deg) translateZ(2px);
}
82% {
bottom: -120%;
z-index: 99;
-webkit-transform: rotateX(-75deg) translateZ(2px);
-ms-transform: rotateX(-75deg) translateZ(2px);
-o-transform: rotateX(-75deg) translateZ(2px);
transform: rotateX(-75deg) translateZ(2px);
}
86% {
bottom: -55%;
z-index: 99;
-webkit-transform: rotateX(-40deg) translateZ(2px);
-ms-transform: rotateX(-40deg) translateZ(2px);
-o-transform: rotateX(-40deg) translateZ(2px);
transform: rotateX(-40deg) translateZ(2px);
}
90% {
bottom: 0;
z-index: 99;
-webkit-transform: rotateX(0) translateZ(2px) scale(1.8);
-ms-transform: rotateX(0) translateZ(2px) scale(1.8);
-o-transform: rotateX(0) translateZ(2px) scale(1.8);
transform: rotateX(0) translateZ(2px) scale(1.8);
}
95% {
bottom: 0;
z-index: 1;
-webkit-transform: scale(1.8);
-ms-transform: scale(1.8);
-o-transform: scale(1.8);
transform: scale(1.8);
}
100% {
-moz-transform: scale(0);
-webkit-transform: scale(0);
-o-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
}
}
.preloader .cameras span.current {
display: block;
}
.preloader .cameras span {
display: none;
perspective: 0;
}
<div class="preloader">
<div class="stack">
<img src="https://preview.ibb.co/jLCafv/stack.jpg">
</div>
<div class="cameras">
<span class="current">
<img src="https://image.ibb.co/i5Dy0v/q10.png" class="camera-img">
<img src="https://image.ibb.co/nJE8YF/q10_sample.jpg" class="polaroid">
</span>
<span>
<img src="https://image.ibb.co/ebc97a/mini8.png" class="camera-img">
<img src="https://image.ibb.co/e5iVfv/mini8_sample.jpg" class="polaroid">
</span>
<span>
<img src="https://image.ibb.co/epVU7a/mini9.png" class="camera-img">
<img src="https://image.ibb.co/cct7Sa/mini9_sample.jpg" class="polaroid">
</span>
<span>
<img src="https://image.ibb.co/hBup7a/mini25.png" class="camera-img">
<img src="https://image.ibb.co/iaOJYF/mini25_sample.jpg" class="polaroid">
</span>
<span>
<img src="https://image.ibb.co/fAXbna/mini70.png" class="camera-img">
<img src="https://image.ibb.co/hNxqfv/mini70_sample.jpg" class="polaroid">
</span>
<span>
<img src="https://image.ibb.co/eu8Gna/mini90.png" class="camera-img">
<img src="https://image.ibb.co/heNj7a/mini90_sample.jpg" class="polaroid">
</span>
<span>
<img src="https://image.ibb.co/fLYStF/wide300.png" class="camera-img">
<img src="https://image.ibb.co/cvQAfv/wide300_sample.jpg" class="polaroid">
</span>
<span>
<img src="https://image.ibb.co/dP3hSa/hellokitty.png" class="camera-img">
<img src="https://image.ibb.co/fW0Mna/hellokitty_sample.jpg" class="polaroid">
</span>
</div>
</div>
Please help

Is it possible to have a combined transform mixin in sass?

I want to recreate the following with scss:
transform: rotate(-20deg) scale(1) skew(-20deg) translate(-40px);
But I want to avoid typing multiple browser prefixes so I have:
#mixin transform($transforms) {
-moz-transform: $transforms;
-o-transform: $transforms;
-ms-transform: $transforms;
-webkit-transform: $transforms;
transform: $transforms;
}
Which works fine with individual transforms such as:
#mixin scale($scale) {
#include transform(scale($scale));
}
I have tried to include the functions
#mixin skewTitle($rot, $sca, $ske, $tran){
#include transform(scale($sca));
#include transform(skew(#{$ske}deg));
#include transform(translate($tran));
#include transform(rot(#{$rot}deg));
}
But it only combines them in succession which causes one to override the other.
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
-webkit-transform: scale(1);
transform: scale(1);
-moz-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-webkit-transform: rotate(-30deg);
transform: rotate(-30deg);
-moz-transform: skew(-20deg);
-o-transform: skew(-20deg);
-ms-transform: skew(-20deg);
-webkit-transform: skew(-20deg);
transform: skew(-20deg);
-moz-transform: translate(-40px);
-o-transform: translate(-40px);
-ms-transform: translate(-40px);
-webkit-transform: translate(-40px);
transform: translate(-40px);
I tried combining it all in something like:
#include transform: rotate(#{$val}deg) scale($val) skew(#{$val}deg) translate($val);
I tried this but it did not work. Is it possible to combine maps to get something along these lines?
Use
#include transform(rotate(-20deg) scale(1) skew(-20deg) translate(-40px));

How to animate a rotated DOM element with CSS

Full code is on: https://jsfiddle.net/k1t7gy8L/
I have the following HTML:
<section class="cd-intro">
<div class="cd-intro-content mask-2">
<div class="content-wrapper">
<div class="inner">
<h1>Animated Intro Section</h1>
<p>A collection of text effects for the intro section of your website</p>
<div class="action-wrapper">
Get started
Learn More
</div>
</div>
</div>
</div>
</section>
with the following CSS:
.mask-2.cd-intro-content .content-wrapper {
position: relative;
width: 100%;
max-width: 650px;
margin: 0 auto;
padding: 2em 0;
overflow: hidden;
transform:rotate(45deg);
background-color: #0F0;
}
.mask-2.cd-intro-content .content-wrapper .inner{
transform:rotate(-45deg);
background-color: #F00;
}
.mask-2.cd-intro-content .content-wrapper > div {
position: relative;
z-index: 1;
}
.mask-2.cd-intro-content .content-wrapper,
.mask-2.cd-intro-content .content-wrapper > div {
animation-duration: 3.5s;
animation-delay: 1.1s;
animation-fill-mode: backwards;
}
.mask-2.cd-intro-content .content-wrapper {
animation-name: cd-mask-wrapper;
}
.mask-2.cd-intro-content .content-wrapper > div {
animation-name: cd-mask-content;
}
#keyframes cd-mask-wrapper {
0% {
-webkit-transform: translateX(50%);
-moz-transform: translateX(50%);
-ms-transform: translateX(50%);
-o-transform: translateX(50%);
transform: translateX(50%);
}
100% {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0);
}
}
#keyframes cd-mask-content {
0% {
-webkit-transform: translateX(-100%);
-moz-transform: translateX(-100%);
-ms-transform: translateX(-100%);
-o-transform: translateX(-100%);
transform: translateX(-100%);
}
100% {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0);
}
}
Everything works like a charm: Except that the rotation on transform:rotate(45deg); only takes effect AFTER the animation. Why is that? How can I rotate it prior to the animation?.
My idea idea is to reveal the content with a diagonal line instead of a vertical line.
You have to declare everything on transform. But also you have to note that translate will be rotated, so with the superpower of geometry you can do this:
#keyframes cd-mask-wrapper {
0% {
-webkit-transform: translateX(50%) rotate(45deg);
-moz-transform: translateX(50%) rotate(45deg);
-ms-transform: translateX(50%) rotate(45deg);
-o-transform: translateX(50%) rotate(45deg);
transform: translateX(50%) rotate(45deg);
}
100% {
-webkit-transform: translateX(0) rotate(45deg);
-moz-transform: translateX(0) rotate(45deg);
-ms-transform: translateX(0) rotate(45deg);
-o-transform: translateX(0) rotate(45deg);
transform: translateX(0) rotate(45deg);
}
}
#keyframes cd-mask-content {
0% {
-webkit-transform: rotate(-45deg) translateX(-100%);
-moz-transform: rotate(-45deg) translateX(-100%);
-ms-transform: rotate(-45deg) translateX(-100%);
-o-transform: rotate(-45deg) translateX(-100%);
transform: rotate(-45deg) translateX(-100%);
}
100% {
-webkit-transform: rotate(-45deg) translateX(0);
-moz-transform rotate(-45deg) translateX(0);
-ms-transform: rotate(-45deg) translateX(0);
-o-transform: rotate(-45deg) translateX(0);
transform: rotate(-45deg) translateX(0);
}
}
Yes. IT is important to translate then rotate the wrapper. And rotate and then translate the content. Test it =)

CSS animation with spin from center

I am using css animations to try and get the green lines to spin around the red circle perfectly alined. I have linked to my fiddle where I have tried to get it working. any advice would be much appropriated. thanks!
[fiddle][1]
[1]: http://jsfiddle.net/3s07jbL4/3/
.badge {
position: relative;
width: 400px;
height:400px;
border-radius: 50%;
transform: rotate(-50deg);
background:red;
}
span {
font: 16px Monaco,monospace;
height: 240px;
position: absolute;
width: 34px;
left: 0px;
top: 0px;
transform-origin: center bottom 0px;
clip: rect(0px, 38px, 63px, 0px);
background:green;
}
span img {
width: 100%;
}
.day1 {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
.day2 {
-webkit-transform: rotate(12deg);
-moz-transform: rotate(12deg);
-ms-transform: rotate(12deg);
-o-transform: rotate(12deg);
transform: rotate(12deg);
}
.day3 {
-webkit-transform: rotate(24deg);
-moz-transform: rotate(24deg);
-ms-transform: rotate(24deg);
-o-transform: rotate(24deg);
transform: rotate(24deg);
}
.day4 {
-webkit-transform: rotate(36deg);
-moz-transform: rotate(36deg);
-ms-transform: rotate(36deg);
-o-transform: rotate(36deg);
transform: rotate(36deg);
}
.day5 {
-webkit-transform: rotate(48deg);
-moz-transform: rotate(48deg);
-ms-transform: rotate(48deg);
-o-transform: rotate(48deg);
transform: rotate(48deg);
}
.day6 {
-webkit-transform: rotate(60deg);
-moz-transform: rotate(60deg);
-ms-transform: rotate(60deg);
-o-transform: rotate(60deg);
transform: rotate(60deg);
}
.day7 {
-webkit-transform: rotate(72deg);
-moz-transform: rotate(72deg);
-ms-transform: rotate(72deg);
-o-transform: rotate(72deg);
transform: rotate(72deg);
}
.day8 {
-webkit-transform: rotate(84deg);
-moz-transform: rotate(84deg);
-ms-transform: rotate(84deg);
-o-transform: rotate(84deg);
transform: rotate(84deg);
}
.day9 {
-webkit-transform: rotate(96deg);
-moz-transform: rotate(96deg);
-ms-transform: rotate(96deg);
-o-transform: rotate(96deg);
transform: rotate(96deg);
}
.day10 {
-webkit-transform: rotate(108deg);
-moz-transform: rotate(108deg);
-ms-transform: rotate(108deg);
-o-transform: rotate(108deg);
transform: rotate(108deg);
}
.day11 {
-webkit-transform: rotate(120deg);
-moz-transform: rotate(120deg);
-ms-transform: rotate(120deg);
-o-transform: rotate(120deg);
transform: rotate(120deg);
}
.day12 {
-webkit-transform: rotate(132deg);
-moz-transform: rotate(132deg);
-ms-transform: rotate(132deg);
-o-transform: rotate(132deg);
transform: rotate(132deg);
}
.day13 {
-webkit-transform: rotate(144deg);
-moz-transform: rotate(144deg);
-ms-transform: rotate(144deg);
-o-transform: rotate(144deg);
transform: rotate(144deg);
}
.day14 {
-webkit-transform: rotate(156deg);
-moz-transform: rotate(156deg);
-ms-transform: rotate(156deg);
-o-transform: rotate(156deg);
transform: rotate(156deg);
}
.day15 {
-webkit-transform: rotate(168deg);
-moz-transform: rotate(168deg);
-ms-transform: rotate(168deg);
-o-transform: rotate(168deg);
transform: rotate(168deg);
}
.day16 {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
}
.day17 {
-webkit-transform: rotate(192deg);
-moz-transform: rotate(192deg);
-ms-transform: rotate(192deg);
-o-transform: rotate(192deg);
transform: rotate(192deg);
}
.day18 {
-webkit-transform: rotate(204deg);
-moz-transform: rotate(204deg);
-ms-transform: rotate(204deg);
-o-transform: rotate(204deg);
transform: rotate(204deg);
}
.day19 {
-webkit-transform: rotate(216deg);
-moz-transform: rotate(216deg);
-ms-transform: rotate(216deg);
-o-transform: rotate(216deg);
transform: rotate(216deg);
}
.day20 {
-webkit-transform: rotate(228deg);
-moz-transform: rotate(228deg);
-ms-transform: rotate(228deg);
-o-transform: rotate(228deg);
transform: rotate(228deg);
}
.day21 {
-webkit-transform: rotate(240deg);
-moz-transform: rotate(240deg);
-ms-transform: rotate(240deg);
-o-transform: rotate(240deg);
transform: rotate(240deg);
}
.day22 {
-webkit-transform: rotate(252deg);
-moz-transform: rotate(252deg);
-ms-transform: rotate(252deg);
-o-transform: rotate(252deg);
transform: rotate(252deg);
}
.day23 {
-webkit-transform: rotate(264deg);
-moz-transform: rotate(264deg);
-ms-transform: rotate(264deg);
-o-transform: rotate(264deg);
transform: rotate(264deg);
}
.day24 {
-webkit-transform: rotate(276deg);
-moz-transform: rotate(276deg);
-ms-transform: rotate(276deg);
-o-transform: rotate(276deg);
transform: rotate(276deg);
}
.day25 {
-webkit-transform: rotate(288deg);
-moz-transform: rotate(288deg);
-ms-transform: rotate(288deg);
-o-transform: rotate(288deg);
transform: rotate(288deg);
}
.day26 {
-webkit-transform: rotate(300deg);
-moz-transform: rotate(300deg);
-ms-transform: rotate(300deg);
-o-transform: rotate(300deg);
transform: rotate(300deg);
}
.day27 {
-webkit-transform: rotate(312deg);
-moz-transform: rotate(312deg);
-ms-transform: rotate(312deg);
-o-transform: rotate(312deg);
transform: rotate(312deg);
}
.day28 {
-webkit-transform: rotate(324deg);
-moz-transform: rotate(324deg);
-ms-transform: rotate(324deg);
-o-transform: rotate(324deg);
transform: rotate(324deg);
}
.day29 {
-webkit-transform: rotate(336deg);
-moz-transform: rotate(336deg);
-ms-transform: rotate(336deg);
-o-transform: rotate(336deg);
transform: rotate(336deg);
}
.day30 {
-webkit-transform: rotate(348deg);
-moz-transform: rotate(348deg);
-ms-transform: rotate(348deg);
-o-transform: rotate(348deg);
transform: rotate(348deg);
}
.day31 {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
.badge
{
-webkit-animation: spin1 2s infinite linear;
-moz-animation: spin1 2s infinite linear;
-o-animation: spin1 2s infinite linear;
-ms-animation: spin1 2s infinite linear;
animation: spin1 2s infinite linear;
width: 400px;
height: 400px;
}
#-webkit-keyframes spin1 {
0% { -webkit-transform: rotate(0deg);}
100% { -webkit-transform: rotate(360deg);}
}
#-moz-keyframes spin1 {
0% { -moz-transform: rotate(0deg); }
100% { -moz-transform: rotate(360deg);}
}
#-o-keyframes spin1 {
0% { -o-transform: rotate(0deg);}
100% { -o-transform: rotate(360deg);}
}
#-ms-keyframes spin1 {
0% { -ms-transform: rotate(0deg);}
100% { -ms-transform: rotate(360deg);}
}
#-keyframes spin1 {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg);}
}
<div id="spin">
<div class="badge">
<span class="day1">
1
</span>
<span class="day2">
1
</span>
<span class="day3">
1
</span>
<span class="day4">
1
</span>
<span class="day5">
1
</span>
<span class="day6">
1
</span>
<span class="day7">
1
</span>
<span class="day8">
1
</span>
<span class="day9">
1
</span>
<span class="day10">
1
</span>
<span class="day11">
1
</span>
<span class="day12">
1
</span>
<span class="day13">
1
</span>
<span class="day14">
1
</span>
<span class="day15">
1
</span>
<span class="day16">
1
</span>
<span class="day17">
1
</span>
<span class="day18">
1
</span>
<span class="day19">
1
</span>
<span class="day20">
1 </span>
<span class="day21">
1 </span>
<span class="day22">
1
</span>
<span class="day23">
1
</span>
<span class="day24">
1
</span>
<span class="day25">
1
</span>
<span class="day26">
1
</span>
<span class="day27">
1
</span>
<span class="day28">
1
</span>
<span class="day29">
1
</span>
<span class="day30">
1
</span>
</div>
</div>
To center all of the day elements horizontally, add left: 50% and margin-left: -17px to the span elements. (-17px is because they are 34px wide, and 17 is half of 34).
To center them vertically, add margin-top: -40px to them. This is because their heights are kind of arbitrary, and adding this will correct it.
http://jsfiddle.net/3s07jbL4/15/

Resources