I have a background image (a schematic) spinning. But I need the center of that image to be lower.
If you think of it like a spinning disc, we should only see the top of the disc, and not the bottom.
I need it to stay within the same border/frame area.
I need the 'product images' to stay centered where they are.
You can see what I have here:
http://www.meteorsite.com/images/spinner/
Thanks in advance for any suggestions...
$("#slideshow > div:gt(0)").hide();
setInterval(function() {
$('#slideshow > div:first')
.fadeOut(3000).next().fadeIn(3000).end()
.appendTo('#slideshow');console.log($('#slideshow > div:first').height()+'-'+$('#slideshow > div:first').width())
}, 5000);
*{margin:0;padding:0;box-sizing:border-box}
#slideshow {
text-align: center;
width: 100%;
height: 100%;
top: 50;
left: 0;
right: 0;
bottom: 0;
}
#slideshow > div {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.wrapper {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
animation: bend 1s linear 0s alternate; /*linear XS is delay before disc
flaps down*/
-webkit-animation-fill-mode: forwards;
}
.vinyl {
width: 600px;
height: 600px;
border-radius: 50%;
animation: moveLeft 0s linear 0s alternate, spin 30s linear 0s infinite; /*
time to spin, etc */
}
.vinyl div {
border: 0px solid #222;
box-sizing: border-box;
height: 100%;
width: 100%;
padding: 5px;
border-radius: 50%;
}
.vinyl__label {
border: none;
background: white;
color: white;
text-align: center;
background-image: url(schemo.gif);
background-size: cover;
background-position: center;
display: flex;
justify-content: center;
align-items: center;
}
#keyframes spin {
0% {
transform: rotateZ(0deg) rotateY(0deg);
}
25% {
transform: rotateZ(90deg) rotateY(0deg);
}
75% {
transform: rotateZ(270deg) rotateY(0deg);
}
100% {
transform: rotateZ(360deg) rotateY(0deg);
}
}
#keyframes bend { /* how far the disc leans back*/
from {
transform: rotateX(55deg);
}
to {
transform: rotateX(55deg);
}
}
#keyframes moveLeft {
transition: all 2s ease-in-out;
-webkit-transition: all 2s ease-in-out;
/** Chrome & Safari **/
-moz-transition: all 2s ease-in-out;
/** Firefox **/
-o-transition: all 2s ease-in-out;
/** Opera **/
from {
transform: translate(350px, 0);
}
to {
transform: translate(350px, 0);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div style="position: absolute;left: 0;right: 0;margin: auto">
<div class="wrapper" style="position: relative;">
<div style="box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);">
<div class="vinyl">
<div class="vinyl__label">
<i class="fa fa-circle" aria-hidden="true"></i>
</div>
</div>
</div>
</div>
<div id="slideshow" style="position: absolute;">
<div style="background: url("http://web3designs.com/spin/slide-1.gif") center center no-repeat;"></div><div style="background: url("http://web3designs.com/spin/slide-2.gif") center center no-repeat; display: none;"></div><div style="background: url("http://web3designs.com/spin/slide-3.gif") center center no-repeat; display: none;"></div></div>
</div>
Here is a quick draft of the disc's position:
You have to add perspective to your .wrapper to make it true 3D.
Then rotate .vinyl around X axis to set a view angle and spin, spin, spin around Z axis:
$(() => {
$("#slideshow > div:gt(0)").hide();
setInterval(function() {
$('#slideshow > div:first')
.fadeOut(3000).next().fadeIn(3000).end()
.appendTo('#slideshow');
//console.log($('#slideshow > div:first').height() + '-' + $('#slideshow > div:first').width())
}, 5000);
})
* {
margin: 0;
padding: 0;
box-sizing: border-box
}
#slideshow {
text-align: center;
width: 100%;
height: 100%;
top: 50;
left: 0;
right: 0;
bottom: 0;
}
#slideshow>div {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.wrapper {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
animation: bend 1s linear 0s alternate;
/*linear XS is delay before disc
flaps down*/
-webkit-animation-fill-mode: forwards;
perspective:1000px;
}
.wrapper > div {overflow:hidden; box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);}
.vinyl {
width: 600px;
height: 600px;
border-radius: 50%; border:solid 1px;
transform: translateY(50%) rotateX(60deg) rotateZ(0);
animation: moveLeft 0s linear 0s alternate, spin 30s linear 0s infinite;
/*
time to spin, etc */
}
.vinyl div {
border: 0px solid #222;
box-sizing: border-box;
height: 100%;
width: 100%;
padding: 5px;
border-radius: 50%;
}
.vinyl__label {
border: none;
background: white;
color: white;
text-align: center;
background-image: url(https://etap.com/images/default-source/product/electrical-single-line-diagram/electrical-single-line-diagram-53a2be6450c286c028629ff00005ae238.jpg?sfvrsn=14);
background-size: cover;
background-position: center;
display: flex;
justify-content: center;
align-items: center;
}
#keyframes spin {
100% {
transform: translateY(50%) rotateX(60deg) rotateZ(360deg);
}
}
#keyframes bend {
/* how far the disc leans back*/
from {
transform: rotateX(55deg);
}
to {
transform: rotateX(55deg);
}
}
#keyframes moveLeft {
transition: all 2s ease-in-out;
-webkit-transition: all 2s ease-in-out;
/** Chrome & Safari **/
-moz-transition: all 2s ease-in-out;
/** Firefox **/
-o-transition: all 2s ease-in-out;
/** Opera **/
from {
transform: translate(350px, 0);
}
to {
transform: translate(350px, 0);
}
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div style="position: absolute;left: 0;right: 0;margin: auto">
<div class="wrapper" style="position: relative;">
<div>
<div class="vinyl">
<div class="vinyl__label">
<i class="fa fa-circle" aria-hidden="true"></i>
</div>
</div>
</div>
</div>
<div id="slideshow" style="position: absolute">
<div style="background: url(http://web3designs.com/spin/slide-1.gif) center center no-repeat;"></div>
<div style="background: url(http://web3designs.com/spin/slide-2.gif) center center no-repeat; display: none;"></div>
<div style="background: url(http://web3designs.com/spin/slide-3.gif) center center no-repeat; display: none;"></div>
</div>
</div>
Related
I'm attempting to have three objects rotating around a circle. So far I've been able to get one object to spin around the circle. I am unable to get more than one without messing up the code. Could anyone advise on the best way to accomplish this? Here is part of the code and a Fiddle. Thanks!
Here is the Demo
.outCircle {
width: 200px;
height: 200px;
background-color: lightblue;
left: 270px;
position: absolute;
top: 50px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
}
.rotate {
width: 100%;
height: 100%;
-webkit-animation: circle 10s infinite linear;
}
.counterrotate {
width: 50px;
height: 50px;
-webkit-animation: ccircle 10s infinite linear;
}
.inner {
width: 100px;
height: 100px;
background: red;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 100px;
position: absolute;
left: 0px;
top: 0px;
background-color: red;
display: block;
}
#-webkit-keyframes circle {
from {
-webkit-transform: rotateZ(0deg)
}
to {
-webkit-transform: rotateZ(360deg)
}
}
#-webkit-keyframes ccircle {
from {
-webkit-transform: rotateZ(360deg)
}
to {
-webkit-transform: rotateZ(0deg)
}
}
<div class="outCircle">
<div class="rotate">
<div class="counterrotate">
<div class="inner">hello
</div>
</div>
</div>
</div>
Jquery solution which works for any number of outer items.
Jquery shamelessly stolen from ThiefMaster♦ and their answer at this Q & A
var radius = 100; // adjust to move out items in and out
var fields = $('.item'),
container = $('#container'),
width = container.width(),
height = container.height();
var angle = 0,
step = (2 * Math.PI) / fields.length;
fields.each(function() {
var x = Math.round(width / 2 + radius * Math.cos(angle) - $(this).width() / 2);
var y = Math.round(height / 2 + radius * Math.sin(angle) - $(this).height() / 2);
if (window.console) {
console.log($(this).text(), x, y);
}
$(this).css({
left: x + 'px',
top: y + 'px'
});
angle += step;
});
body {
padding: 2em;
}
#container {
width: 200px;
height: 200px;
margin: 10px auto;
border: 1px solid #000;
position: relative;
border-radius: 50%;
animation: spin 10s linear infinite;
}
.item {
width: 30px;
height: 30px;
line-height: 30px;
text-align: center;
border-radius: 50%;
position: absolute;
background: #f00;
animation: spin 10s linear infinite reverse;
}
#keyframes spin {
100% {
transform: rotate(1turn);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
</div>
How about this, demo at the bottom with 3 circles:
.outCircle {
width: 200px;
height: 200px;
background-color: lightblue;
left: 270px;
position: absolute;
top: 50px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
}
.duringTwentyOne {
-webkit-animation-duration: 21s;
}
.duringTen {
-webkit-animation-duration: 10s;
}
.duringFour {
-webkit-animation-duration: 4s;
}
.infinite {
-webkit-animation-iteration-count: infinite;
}
.linear {
-webkit-animation-timing-function: linear;
}
.counter {
width: 50px;
height: 50px;
-webkit-animation-duration: inherit;
-webkit-animation-direction: reverse;
-webkit-animation-timing-function: inherit;
-webkit-animation-iteration-count: inherit;
-webkit-animation-name: inherit;
}
.rotate {
width: 100%;
height: 100%;
-webkit-animation-name: circle;
position: relative;
z-index : 10;
display : block;
}
.second {
top : -100%;
}
.thirdBigger {
top : -240%;
left: -40%;
width:150%;
height: 150%;
}
.inner {
width: 100px;
height: 100px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 100px;
position: absolute;
left: 0px;
top: 0px;
background-color: red;
display: block;
}
.red {
background: red;
}
.green {
background: green;
}
#keyframes circle {
from {-webkit-transform: rotateZ(0deg)}
to {-webkit-transform: rotateZ(360deg)}
}
<div class="outCircle">
<div class="rotate linear infinite duringTen">
<div class="counter">
<div class="inner">hello
</div>
</div>
</div>
<div class="second rotate linear infinite duringFour">
<div class="counter">
<div class="inner red">bye bye
</div>
</div>
</div>
<div class="thirdBigger rotate linear infinite duringTwentyOne">
<div class="counter">
<div class="inner green">s'up
</div>
</div>
</div>
</div>
Here is a more generic idea with less of code where you don't need JS and you only need to apply an animation to the item (not the container). The trick is to make all the elements at the same position and using the same animation then with the delay we can have the needed result:
#container {
width: 200px;
height: 200px;
margin: 40px auto;
border: 1px solid #000;
display:grid;
grid-template-columns:30px;
grid-template-rows:30px;
place-content: center;
border-radius: 50%;
}
.item {
grid-area:1/1;
line-height: 30px;
text-align: center;
border-radius: 50%;
background: #f00;
animation: spin 12s var(--d,0s) linear infinite; /* duration = 12s, numbor of item = 6 so a delay of 12/6 = 2s */
transform:rotate(0) translate(100px) rotate(0);
}
#keyframes spin {
100% {
transform:rotate(1turn) translate(100px) rotate(-1turn);
}
}
<div id="container">
<div class="item" style="--d:0s">1</div>
<div class="item" style="--d:-2s">2</div>
<div class="item" style="--d:-4s">3</div>
<div class="item" style="--d:-6s">4</div>
<div class="item" style="--d:-8s">5</div>
<div class="item" style="--d:-10s">6</div>
</div>
We can easily scale to any number using some CSS variables:
#container {
--n:7; /* number of item */
--d:12s; /* duration */
width: 200px;
height: 200px;
margin: 40px auto;
border: 1px solid #000;
display:grid;
grid-template-columns:30px;
grid-template-rows:30px;
place-content: center;
border-radius: 50%;
}
.item {
grid-area:1/1;
line-height: 30px;
text-align: center;
border-radius: 50%;
background: #f00;
animation: spin var(--d) linear infinite;
transform:rotate(0) translate(100px) rotate(0);
}
#keyframes spin {
100% {
transform:rotate(1turn) translate(100px) rotate(-1turn);
}
}
.item:nth-child(1) {animation-delay:calc(-0*var(--d)/var(--n))}
.item:nth-child(2) {animation-delay:calc(-1*var(--d)/var(--n))}
.item:nth-child(3) {animation-delay:calc(-2*var(--d)/var(--n))}
.item:nth-child(4) {animation-delay:calc(-3*var(--d)/var(--n))}
.item:nth-child(5) {animation-delay:calc(-4*var(--d)/var(--n))}
.item:nth-child(6) {animation-delay:calc(-5*var(--d)/var(--n))}
.item:nth-child(7) {animation-delay:calc(-6*var(--d)/var(--n))}
.item:nth-child(8) {animation-delay:calc(-7*var(--d)/var(--n))}
.item:nth-child(9) {animation-delay:calc(-8*var(--d)/var(--n))}
/*.item:nth-child(N) {animation-delay:calc(-(N - 1)*var(--d)/var(--n))}*/
<div id="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
</div>
<div id="container" style="--n:5;--d:5s">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
</div>
<div id="container" style="--n:9">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
</div>
Not sure if this is what you are after, but you need to position your rotating circles absolutely (so they don't interfere with each other) and then give them their own animation:
For the counter rotation, just make them then minus of what the rotation degrees is and that will keep your text horizontal
.outCircle {
width: 200px;
height: 200px;
background-color: lightblue;
left: 270px;
position: absolute;
top: 50px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
}
.rotate {
width: 100%;
height: 100%;
position: absolute; /* add this */
}
.counterrotate {
width: 100px;
height: 100px;
}
.inner {
width: 100px;
height: 100px;
text-align: center;
vertical-align: middle;
background: red;
border-radius: 100px;
background-color: red;
display: table-cell;
}
.anim1 {
-webkit-animation: circle1 10s infinite linear;
}
.anim1 .counterrotate {
-webkit-animation: ccircle1 10s infinite linear;
}
.anim2 {
-webkit-animation: circle2 10s infinite linear;
}
.anim2 .counterrotate {
-webkit-animation: ccircle2 10s infinite linear;
}
.anim3 {
-webkit-animation: circle3 10s infinite linear;
}
.anim3 .counterrotate {
-webkit-animation: ccircle3 10s infinite linear;
}
#-webkit-keyframes circle1 {
from {
-webkit-transform: rotateZ(0deg)
}
to {
-webkit-transform: rotateZ(360deg)
}
}
#-webkit-keyframes ccircle1 {
from {
-webkit-transform: rotateZ(0deg)
}
to {
-webkit-transform: rotateZ(-360deg)
}
}
#-webkit-keyframes circle2 {
from {
-webkit-transform: rotateZ(90deg)
}
to {
-webkit-transform: rotateZ(450deg)
}
}
#-webkit-keyframes ccircle2 {
from {
-webkit-transform: rotateZ(-90deg)
}
to {
-webkit-transform: rotateZ(-450deg)
}
}
#-webkit-keyframes circle3 {
from {
-webkit-transform: rotateZ(180deg)
}
to {
-webkit-transform: rotateZ(540deg)
}
}
#-webkit-keyframes ccircle3 {
from {
-webkit-transform: rotateZ(-180deg)
}
to {
-webkit-transform: rotateZ(-540deg)
}
}
<div class="outCircle">
<div class="rotate anim1">
<div class="counterrotate">
<div class="inner">hello
</div>
</div>
</div>
<div class="rotate anim2">
<div class="counterrotate">
<div class="inner">hello
</div>
</div>
</div>
<div class="rotate anim3">
<div class="counterrotate">
<div class="inner">hello
</div>
</div>
</div>
</div>
Use translateX.
See this jsfiddle.
I made the outer circle position: relative and the inner ones position: absolute, so they lie on top of each others mids (which is just for illustration, this is just for positioning the child circles on the same spot; grouping them).
Then, from this center spot, the translateX tells the animation to give it a radius of in this case 100px (which is the radius of the outer circle).
There you go.
.circleLink {
color: #ececec;
text-transform: uppercase;
font-size: 24px;
line-height: 120%;
position: relative;
display: inline-block;
border: 1px solid blue;
width: 200px;
height: 200px;
-moz-box-flex: 0;
flex: 0 0 270px;
display: -moz-box;
display: flex;
-moz-box-pack: center;
justify-content: center;
-moz-box-align: center;
align-items: center;
border-radius: 50%;
}
.round>span:first-child {
position: relative;
color:blue;
}
.round>span:first-child::before {
content: "";
position: absolute;
width: 100%;
height: 0;
border: 1px solid #ececec;
bottom: -5px;
background: #ececec;
border-radius: 10px;
left: 0;
}
.round>span:nth-child(2) {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
transform: rotate(90deg);
}
.circleLink>span:nth-child(2) {
position: absolute;
z-index: 1;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.circleLink>span:nth-child(2) span {
position: absolute;
top: -webkit-calc(50% - 0.5px);
top: -moz-calc(50% - .5px);
top: calc(50% - 0.5px);
left: 50%;
z-index: 1;
width: 50%;
height: 1px;
-webkit-transform-origin: left;
-moz-transform-origin: left;
transform-origin: left;
-webkit-animation: linkRotate 5s linear 0s infinite;
-moz-animation: linkRotate 5s linear 0s infinite;
animation: linkRotate 5s linear 0s infinite;
-webkit-animation-play-state: paused;
-moz-animation-play-state: paused;
animation-play-state: paused;
}
.circleLink>span:nth-child(2) span:before {
content: "";
position: absolute;
width: 20px;
height: 20px;
top: -10px;
right: -10px;
background: #42B4EF;
border-radius: 50%;
}
.circleLink:hover>span:nth-child(2) span {
-webkit-animation-play-state: running;
-moz-animation-play-state: running;
animation-play-state: running;
}
#-webkit-keyframes linkRotate {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg)
}
to {
-webkit-transform: rotate(1turn);
transform: rotate(1turn)
}
}
#-moz-keyframes linkRotate {
0% {
-moz-transform: rotate(0deg);
transform: rotate(0deg)
}
to {
-moz-transform: rotate(1turn);
transform: rotate(1turn)
}
}
#keyframes linkRotate {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
transform: rotate(0deg)
}
to {
-webkit-transform: rotate(1turn);
-moz-transform: rotate(1turn);
transform: rotate(1turn)
}
}
<div class="round">
<a href="#" class="circleLink">
<span>Loram</span>
<span><span></span></span>
</a>
</div>
as a newbie in CSS animations i'm trying to make some spinners,
Unfortunately i am not able to make repeat a cycle of animations and i'm searching help!
Here is the code:
.rotate {
transform: rotate(-45deg);
display: flex;
}
#column {
display: flex;
flex-direction: column;
}
.block3 {
width: 45px;
height: 45px;
background-color: black;
margin: 1px;
animation: fade .4s linear both;
animation-delay: 0s;
}
.block4 {
width: 45px;
height: 45px;
background-color: black;
margin: 1px;
animation: fade .4s linear both;
animation-delay: .4s;
}
.block2 {
width: 45px;
height: 45px;
background-color: black;
margin: 1px;
animation: fade .4s linear both;
animation-delay: .8s;
}
.block1 {
width: 45px;
height: 45px;
background-color: black;
margin: 1px;
animation: fade .4s linear both;
animation-delay: 1.2s;
}
#keyframes fade {
0% {
opacity: 1;
transform: perspective(140px) rotateX(-180deg);
}
100% {
opacity: 0;
}
}
<!DOCTYPE html>
<html lang="it">
<head>
<style>
body {
position: absolute;
margin: 0;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.margin {
margin-top: 200px;
left: 50%;
transform: translate(-50%);
position: absolute;
}
</style>
</head>
<body>
<section class="animation rotate">
<div id="column">
<div class="block1"></div>
<div class="block2"></div>
</div>
<div id="column">
<div class="block3"></div>
<div class="block4"></div>
</div>
</section>
</body>
</html>
I even tried with infinite attribute but obviously it continues to repeat every block:
.rotate {
transform: rotate(-45deg);
display: flex;
}
#column {
display: flex;
flex-direction: column;
}
.block3 {
width: 45px;
height: 45px;
background-color: black;
margin: 1px;
animation: fade .4s infinite linear both;
animation-delay: 0s;
}
.block4 {
width: 45px;
height: 45px;
background-color: black;
margin: 1px;
animation: fade .4s infinite linear both;
animation-delay: .4s;
}
.block2 {
width: 45px;
height: 45px;
background-color: black;
margin: 1px;
animation: fade .4s infinite linear both;
animation-delay: .8s;
}
.block1 {
width: 45px;
height: 45px;
background-color: black;
margin: 1px;
animation: fade .4s infinite linear both;
animation-delay: 1.2s;
}
#keyframes fade {
0% {
opacity: 1;
transform: perspective(140px) rotateX(-180deg);
}
100% {
opacity: 0;
}
}
<!DOCTYPE html>
<html lang="it">
<head>
<style>
body {
position: absolute;
margin: 0;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.margin {
margin-top: 200px;
left: 50%;
transform: translate(-50%);
position: absolute;
}
</style>
</head>
<body>
<section class="animation rotate">
<div id="column">
<div class="block1"></div>
<div class="block2"></div>
</div>
<div id="column">
<div class="block3"></div>
<div class="block4"></div>
</div>
</section>
</body>
</html>
So in conclusion:
block1 executes, block2 executes, block3 executes, block4 executes then repeat from block1
You will need to create a keyframe for each block:
.rotate {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%) rotate(-45deg) ;
display: flex;
flex-wrap: wrap;
width: 100px; /* change this to control the size */
}
.rotate div {
flex:1 1 48%; /* little less than 50% to consider the margin */
margin: 1px;
background-color: black;
animation: 2s linear infinite;
}
/* maintain square ratio*/
.rotate div::before {
content: "";
display: block;
padding-top: 100%;
}
/**/
.rotate div:nth-child(1) { animation-name:fade4}
.rotate div:nth-child(2) { animation-name:fade1}
.rotate div:nth-child(3) { animation-name:fade3}
.rotate div:nth-child(4) { animation-name:fade2}
/* [0% first one 20%][20% second one 40%][40% third one 60%][60% fourth one 80%][80% pause 100%] */
#keyframes fade1 {
0% {
opacity: 1;
transform: perspective(140px) rotateX(-180deg);
}
20%,100% {
opacity: 0;
}
}
#keyframes fade2 {
0%,20% {
opacity: 1;
transform: perspective(140px) rotateX(-180deg);
}
40%,100% {
opacity: 0;
}
}
#keyframes fade3 {
0%,40% {
opacity: 1;
transform: perspective(140px) rotateX(-180deg);
}
60%,100% {
opacity: 0;
}
}
#keyframes fade4 {
0%,60% {
opacity: 1;
transform: perspective(140px) rotateX(-180deg);
}
80%,100% {
opacity: 0;
}
}
<section class="animation rotate">
<div></div>
<div></div>
<div></div>
<div></div>
</section>
I use CSS Pie Timer, and I struggle to make my pie loading animation run only once.
The order I want the animation to be in:
the circle is not shown
the circle is starting to fill up with a border color
the circle get filled fully
the circle stays filled (and doesn't repeat)
Demo here
<div class="wrapper">
<div class="pie spinner"></div>
<div class="pie filler"></div>
<div class="mask"></div>
</div>
Help will be appreciated!
You just have to remove animation-iteration-count - infinite and add animation-fill-mode as forwards.
Here is the working code
.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 forwards;
}
.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) forwards 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) forwards;
}
#keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
#keyframes opa {
0% {
opacity: 1;
}
50%, 100% {
opacity: 0;
}
}
<div class="wrapper">
<div class="pie spinner"></div>
<div class="pie filler"></div>
<div class="mask"></div>
</div>
I've built a UI of a loop of cards however I'm struggling to make the UI work for a fluid screen layout. Can anyone suggest how I could arrange a series of divs into an outer container that can vary in heights and widths? To make things a little easier the container will always follow a portrait dimension.
I've also added a jsFiddle link to allow you to try editing the html / css.
http://jsfiddle.net/w2we2gyd/
<div class="card-preview">
<p>1</p>
<div class='circle'></div>
<div class='card-preview-top'></div>
<div class='card-preview-bottom'></div>
</div>
First off: I'm not a fan of how your CSS is laid out, try to use a preprocessor to structure your code and then just output it regularly. Apart from that, adding the following lines does, make it responsive:
.card-preview p {
left: 50%;
top: 50%;
right: auto;
bottom: auto;
width: auto;
height: auto;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.loop-container{
height:100%;
}
.loop-status, .card-preview {
height: 29%;
}
/* Loop container could be variable widths / height */
body, html {
height: 100%;
}
.loop-container
{
width:100%;
height:100%;
}
.loop-status, .card-preview {
position: relative;
top: 0;
left: 0;
float: left;
margin: 10px 5px 5px 5px;
width: 29%;
height: 29%;
background: #fff; }
.loop-status .circle, .card-preview .circle {
border-radius: 50%;
width: 75%;
height: 45%;
z-index: 2;
position: absolute;
top: 25%;
background-color: white;
left: 0;
border: solid 4px #00b9aa;
right: 0;
margin-left: auto;
margin-right: auto;
top: 0;
bottom: 0;
margin-top: auto;
margin-bottom: auto; }
.loop-status .circle i, .card-preview .circle i {
display: none; }
.loop-status .circle.loop-correct, .card-preview .circle.loop-correct {
background-color: #00b9aa; }
.loop-status .circle.loop-correct i, .card-preview .circle.loop-correct i {
display: inline;
margin: auto;
text-align: center;
vertical-align: middle;
width: 100%;
height: 100%;
display: block;
color: white;
font-size: 50px;
padding: 10px; }
.loop-status .circle.loop-incorrect, .card-preview .circle.loop-incorrect {
background-color: #A23842; }
.loop-status .circle.loop-incorrect i, .card-preview .circle.loop-incorrect i {
display: inline;
margin: auto;
text-align: center;
vertical-align: middle;
width: 100%;
height: 100%;
display: block;
color: white;
font-size: 50px;
padding: 10px; }
.card-preview {
cursor: pointer;
border: solid 4px #00b9aa;
border-radius: 10px;
overflow: hidden;
-webkit-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3);
box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3);
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
transition: all 0.5s ease; }
.card-preview:hover {
-webkit-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.9);
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.9);
-webkit-transform: scale(1.05, 1.05);
-moz-transform: scale(1.05, 1.05);
-o-transform: scale(1.05, 1.05);
-ms-transform: scale(1.05, 1.05);
transform: scale(1.05, 1.05); }
.card-preview p {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
text-align: center;
color: #00534c;
font: 25px/105px sans serif;
display: inline-block;
z-index: 3;
line-height: 6.5em; }
.card-preview.current .card-preview-top {
-webkit-animation: pulsate 2s infinite;
-moz-animation: pulsate 2s infinite;
-o-animation: pulsate 2s infinite;
-ms-animation: pulsate 2s infinite;
animation: pulsate 2s infinite; }
.card-preview.answered .card-preview-top {
background-color: white; }
.card-preview.hinted .card-preview-top {
-webkit-animation: pulsateError 2s infinite;
-moz-animation: pulsateError 2s infinite;
-o-animation: pulsateError 2s infinite;
-ms-animation: pulsateError 2s infinite;
animation: pulsateError 2s infinite; }
.card-preview .card-preview-top {
position: relative;
top: 0px;
left: 0px;
width: 100%;
height: 50%;
background-color: #727272;
z-index: 1; }
.card-preview .card-preview-bottom {
position: relative;
top: 0px;
left: 0px;
width: 100%;
height: 50%;
background-color: #00b9aa;
z-index: 1; }
/* Added code below */
.card-preview p {
left: 50%;
top: 50%;
right: auto;
bottom: auto;
width: auto;
height: auto;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.loop-container{
height:100%;
}
.loop-status, .card-preview {
height: 29%;
}
<div class='loop-container'>
<div class="card-preview">
<p>1</p>
<div class='circle'></div>
<div class='card-preview-top'></div>
<div class='card-preview-bottom'></div>
</div>
<div class="card-preview">
<p>2</p>
<div class='circle'></div>
<div class='card-preview-top'></div>
<div class='card-preview-bottom'></div>
</div>
<div class="card-preview">
<p>3</p>
<div class='circle'></div>
<div class='card-preview-top'></div>
<div class='card-preview-bottom'></div>
</div>
<div class="card-preview">
<p>4</p>
<div class='circle'></div>
<div class='card-preview-top'></div>
<div class='card-preview-bottom'></div>
</div>
<!-- Cards should appear in a loop with an empty middle -->
<div class="loop-status" class='overview'>
</div>
<div class="card-preview">
<p>5</p>
<div class='circle'></div>
<div class='card-preview-top'></div>
<div class='card-preview-bottom'></div>
</div>
<div class="card-preview">
<p>6</p>
<div class='circle'></div>
<div class='card-preview-top'></div>
<div class='card-preview-bottom'></div>
</div>
<div class="card-preview">
<p>7</p>
<div class='circle'></div>
<div class='card-preview-top'></div>
<div class='card-preview-bottom'></div>
</div>
<div class="card-preview">
<p>8</p>
<div class='circle'></div>
<div class='card-preview-top'></div>
<div class='card-preview-bottom'></div>
</div>
</div>
The only issue is that you want a margin in pixels, well, you can solve this in the following way:
.loop-status, .card-preview {
/* non-calc supporting fallback */
height: 29%;
/* calc supporting browsers will do this right */
height: calc(100% / 3 - 15px);
width: 29%;
width: calc(100% / 3 - 10px);
margin: 2%;
margin: calc(10px) calc(5px) calc(5px) calc(5px);
}
The HTML
<div id='loader'>
<div id='loaderLargeSlice' class='loaderSlice'>
<div class='arc'></div>
<div class='arc'></div>
<div class='arc'></div>
</div>
</div>
The CSS
#loader{
position: relative;
width: 100px;
height: 100px;
margin: 14px;
border-radius: 50%;
background: none;
}
.loaderSlice
{
position:absolute;
display:block;
opacity: 0.5;
}
#loaderLargeSlice
{
height: 100px;
width: 100px;
animation: spin 4s linear 0s infinite forwards;
-webkit-animation: spin 4s linear 0s infinite forwards;
}
.arc
{
position: absolute;
top: -14px;
left: -14px;
width: 100%;
height: 100%;
background: none;
border: 14px solid rgba(0,0,0,0);
border-top-color: black;
border-radius: 50%;
}
.arc + .arc
{
transform: rotate(70deg);
-webkit-transform: rotate(70deg);
}
.arc + .arc + .arc
{
transform: rotate(140deg);
-webkit-transform: rotate(140deg);
}
The Problem
Firefox shows ragged edges
Anyone know of a fix?
Answering as unfixable. See #Eevee's comment on the main post.