Seamless CSS Animations - html

I have a html program with a css and js file, and i have a continuously looping spin animation on one of my elements, when i hover over it it changes its animation to a different animation, but when i hover it, it instantly moves back to 0deg causing a uncomfortable jump, is there a way for the animation to know where it is currently to start at that position?
here's my code, its all of it so its a bit long
body{
background: #808080;
}
.Glow{
transform: rotate(90deg);
background:blue;
position: absolute;
border-radius: 50%;
overflow: hidden;
}
.Glow:nth-child(1){
width: 300px;
height: 300px;
background: #ffffff;
-webkit-clip-path: polygon(00% 100%, 50% 50%, 100% 100%);
}
.Glow:nth-child(2){
width: 300px;
height: 300px;
background: #ffffff;
-webkit-clip-path: polygon(0% 0%, 50% 50%, 100% 0%);
}
.Glow:nth-child(3){
width: 270px;
height: 270px;
margin: 15px;
background: #808080;
}
.Glow:nth-child(4){
width: 300px;
height: 300px;
-webkit-clip-path: polygon(30% 100%, 45% 85%, 50% 50%, 55% 85%, 70% 100%);
background: #ffffff;
}
.Glow:nth-child(5){
width: 300px;
height: 300px;
-webkit-clip-path: polygon(30% 0%, 45% 15%, 50% 50%, 55% 15%, 70% 0%);
background: #ffffff;
}
.Glow:nth-child(6){
left: 45%;
top: 19%;
border-radius: 0%;
width: 3px;
height: 100px;
background: linear-gradient(#808080, #cccccc);
animation: null;
transform: rotate(0deg);
}
.Glow:nth-child(7){
left: 46.6%;
top: 19%;
border-radius: 0%;
width: 3px;
height: 100px;
background: linear-gradient(#808080, #cccccc);
animation: null;
transform: rotate(0deg);
}
.Glow:nth-child(8){
width: 150px;
height: 150px;
margin: 75px;
-webkit-clip-path: polygon(0% 0%, 0% 30%, 8% 39%, 8% 61%, 0% 70%, 0% 100%, 100% 100%, 100% 70%, 92% 61%, 92% 39%, 100% 30%, 100% 0%);
background: #ffffff;
}
.Glow:nth-child(9){
width: 150px;
height: 150px;
margin: 75px;
-webkit-clip-path: polygon(6% 41%, 6% 60%, 0% 66%, 0% 34%);
background: #ffffff;
}
.Glow:nth-child(10){
width: 150px;
height: 150px;
margin: 75px;
-webkit-clip-path: polygon(94% 41%, 94% 60%, 100% 66%, 100% 34%);
background: #ffffff;
}
.Glower:hover{
left: 37%;
top: 20%;
animation: spin1 2s linear 0s infinite;
}
.Glower{
transform: rotate(0deg);
position: absolute;
left: 37%;
top: 20%;
width: 300px;
height: 300px;
animation: spin 4s linear 0s infinite forwards;
}
#-webkit-keyframes spin{
100%{
-webkit-transform: rotate(450deg);
}
}
#-webkit-keyframes spinside{
100%{
-webkit-transform: rotate(270deg);
}
}
#-webkit-keyframes openCircle1{
100%{
top: 40%;
}
}
#-webkit-keyframes openCircle2{
100%{
top: 10%;
}
}
#-webkit-keyframes spin1{
0%{
-webkit-transform: scale(1) rotate(0deg);
}
25%{
-webkit-transform: scale(.9) rotate(120deg);
}
75%{
-webkit-transform: scale(1.1) rotate(240deg);
}
100%{
-webkit-transform: scale(1) rotate(360deg);
}
}
Edit: i use the spin1 and the spin animation btw
Edit 2: here's the codepen upload https://codepen.io/Inertiality/pen/mEBkvN
Edit 3: am i able to use transitions? cause i dont see how those could work with the animations

Related

Is there a way to get a checkbox to make several elements disappear without js?

I'm trying to make a sort of "cover" for a text post. However, the checkbox I coded with display: none is not working. I am not sure if it's because of the hierarchy, or because I added a hover to make it spin. I've tried moving it around and taking out the hover but it doesn't work. While I know this would be easier made with js, the platform I'm going to use this at doesn't support Js.
Here is the part of the html code, I'm working on. I want everythin inside "doubleport" to disapear, with a fade out transition.
<div class="doubletrouble">
<div class= "doubleport" id="porting"> <div class= "menu"><label id=portbtnx> <input type="checkbox"> Double<br>Trouble</label>
<div id= portdata> Dato desu </div>
<div id= portdata> Dato largo </div>
</div>
<div class= "doubledisp">
<div id= "portleft"></div><div id="portright"></div>
</div></div>
then the css for the checkbox formating
.menu #portbtnx{
width: 125px;
height: 125px;
background: radial-gradient(
rgba(252,255,200,1) 5%,
rgba(229,180,59,1) 35%,
rgba(91,16,134,1) 90%);
margin: 5px;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
clip-path: polygon(20% 0%, 0% 20%, 30% 50%, 0% 80%, 20% 100%, 50% 70%, 80% 100%, 100% 80%, 70% 50%, 100% 20%, 80% 0%, 50% 30%);
color: (--spacepurp);
font-family: 'Lobster', cursive;
font-size: 20px;}
.doubletrouble #portbtnx:hover {
animation: spin 6s;}
#-moz-keyframes spin {
100% { -moz-transform: rotate(360deg); }
}
#-webkit-keyframes spin {
100% { -webkit-transform: rotate(360deg); }
}
#keyframes spin {
100% {
-webkit-transform: rotate(360deg);
transform:rotate(360deg);
}
}
Lastly the code I have for the checkbox and transition:
.doubletrouble input[type=checkbox]{display:none}
input[type=checkbox label="portbtnx"]:checked~ .doubleport .menu .doubledisp {
display: none;
animation: disapear 4s;
}
#keyframes disapear{ from {opacity:1} to {opacity:0;}}
If anyone can help it'd be extremely appreciated. Cheers!
Here is the full code so far, please note that the css is not finished. Since it's quite long I decided to keep the snips as well.
.doubletrouble{
height: 815px;
width: 640px;
background-color: var(--spacepurp, #3f1d59);
padding: 10px;
}
.doubletrouble .doubleport{
height: 795px;
width: 620px;
background: linear-gradient(0deg, rgba(175,135,34,1) 0%, rgba(91,16,134,1) 50%, rgba(175,135,34,1) 100%);;
padding: 10px;}
.doubleport .doubledisp{
display: flex;
possition: relative;
z-index: 1;
}
.doubleport #portleft{
height: 795px;
width: 325px;
background-image: url(https://i.imgur.com/nJr1QCa.png);
clip-path: polygon(0 0, 100% 0%, 90% 100%, 0 100%);
margin-right: -10px;
}
.doubleport #portright{
height: 795px;
width: 325px;
clip-path: polygon(10% 0%, 100% 0%, 100% 100%, 0% 100%);
background-image: url(https://i.imgur.com/SuO1nGg.png);
margin-left: -10px;
}
.doubleport .menu{
position: absolute;
display: inline;
padding: 270px;
width: 150px;
margin-top: 100px;
margin-left: -30px;
z-index: 2;
}
.menu #portbtnx{
width: 125px;
height: 125px;
background: radial-gradient(
rgba(252,255,200,1) 5%,
rgba(229,180,59,1) 35%,
rgba(91,16,134,1) 90%);
margin: 5px;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
clip-path: polygon(20% 0%, 0% 20%, 30% 50%, 0% 80%, 20% 100%, 50% 70%, 80% 100%, 100% 80%, 70% 50%, 100% 20%, 80% 0%, 50% 30%);
color: (--spacepurp);
font-family: 'Lobster', cursive;
font-size: 20px;}
.doubletrouble #portbtnx:hover {
animation: spin 6s;}
#-moz-keyframes spin {
100% { -moz-transform: rotate(360deg); }
}
#-webkit-keyframes spin {
100% { -webkit-transform: rotate(360deg); }
}
#keyframes spin {
100% {
-webkit-transform: rotate(360deg);
transform:rotate(360deg);
}
}
.doubleport #portdata{
margin: 5px;
margin-left: -5px;
margin-top: 10px;
text-align: center;
background: linear-gradient(90deg, rgba(91,16,134,1) 0%, rgba(229,180,59,1) 50%, rgba(252,255,200,1) 100%);
color: (--spacepurp);
font-family: 'Lobster', cursive;
opacity: .8;
}
#portdata:hover{background: linear-gradient(90deg,
rgba(252,255,200,1) 0%,
rgba(229,180,59,1) 50%, rgba(91,16,134,1) 100%);
opacity: 1;
transition: opacity .35s ease-in-out;
-moz-transition: opacity .35s ease-in-out;
-webkit-transition: opacity .35s ease-in-out; }
.doubletrouble input[type=checkbox]{display:none}
input[type=checkbox label="portbtnx"]:checked~ .doubleport .menu .doubledisp {
display: none;
animation: disapear 4s;
}
#keyframes disapear{ from {opacity:1} to {opacity:0;}}
<head> <link rel="stylesheet" href="https://files.jcink.net/uploads2/nikudoesthings/nikullection_icons/nikuicons.css"/> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lobster&display=swap" rel="stylesheet"> </head>
<body>
<div class="doubletrouble">
<div class= "doubleport" id="porting"> <div class= "menu"><label id=portbtnx> <input type="checkbox"> Double<br>Trouble</label>
<div id= portdata> Dato desu </div>
<div id= portdata> Dato largo </div>
</div>
<div class= "doubledisp">
<div id= "portleft"></div><div id="portright"></div>
</div></div>
<div class= "dobletitle">
<div class= "mojinaka">
<div class="mojihako">
<div class= "mojisoto">
</div>
</div>
</div>
</div>
</div> </body>
Try
.doubletrouble:checked #dataport{
Display:none
}
Or
Visibility:0%;
It depends on the use case

Css import and page style

Hello and thank you in advance.
I have 3D cube on my site.
When I import external CSS file, it just makes my cube go wrong. Cube goes to left, and I can't move it again.
When I delete external css, everything works as it should.
#import url("mojmeni.css"); - located in head
body { font-family: sans-serif;
font-family: monospace;
text-transform: uppercase;
backgroud: #999;
}
.container {
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
}
ul {
display: flex;
flex-direction: row;
font-size: 22px;
}
li {
position: relative;
list-style-type: none;
margin-right: 50px;
cursor: pointer;
color: black;
}
li:last-child {
margin-right: 0px;
}
li:after {
content: "";
position: absolute;
z-index: -1;
left: 50%;
transform: translateX(-50%) rotate(0deg);
}
li:nth-child(1):after {
background: #ED4337;
}
li:nth-child(2):after {
background: #A1D3A2;
}
li:nth-child(3):after {
background: #50B8E7;
}
li:nth-child(4):after {
background: #efe200;
}
li:nth-child(1):after {
clip-path: polygon(6% 10%, 100% 0, 64% 65%, 28% 65%);
height: 85px;
width: 75px;
bottom: -47px;
animation: stretch 2s ease infinite;
}
#keyframes stretch {
25% {
transform: translateX(-50%) rotate(2deg) scaleY(0.93);
}
50% {
transform: translateX(-50%) rotate(-2deg) scaleX(0.93);
clip-path: polygon(6% 20%, 100% 0, 64% 65%, 28% 65%);
}
75% {
transform: translateX(-50%) rotate(3deg) scale(1.05);
}
}
li:nth-child(2):after {
clip-path: polygon(61% 0%, 100% 19%, 71% 100%, 0% 100%);
height: 55px;
width: 75px;
bottom: -18px;
animation: stretch2 1.5s ease infinite;
}
#keyframes stretch2 {
25% {
transform: translateX(-50%) rotate(-2deg) scaleY(1.05);
}
50% {
transform: translateX(-50%) rotate(2deg) scaleY(0.93) scaleX(1.06);
clip-path: polygon(61% 0%, 100% 19%, 71% 100%, 12% 100%);
}
75% {
transform: translateX(-50%) rotate(3deg) scale(1.05);
clip-path: polygon(61% 0%, 80% 19%, 71% 100%, 12% 100%);
}
}
li:nth-child(3):after {
clip-path: polygon(0% 0%, 100% 0%, 100% 99%, 0% 57%);
height: 55px;
width: 45px;
bottom: -18px;
animation: stretch3 2s ease infinite;
}
#keyframes stretch3 {
25% {
transform: translateX(-50%) rotate(-2deg) scaleY(1.05);
}
50% {
transform: translateX(-50%) rotate(2deg) scaleY(0.93) scaleX(1.06);
clip-path: polygon(10% 5%, 100% 0%, 100% 99%, 0% 57%);
}
75% {
transform: translateX(-50%) rotate(3deg) scale(1.05);
clip-path: polygon(0% 0%, 100% 0%, 100% 99%, 10% 37%);
}
}
li:nth-child(4):after {
clip-path: polygon(0% 40%, 100% 0%, 100% 99%, 19% 100%);
height: 55px;
width: 45px;
bottom: -18px;
animation: stretch4 2s ease infinite;
}
#keyframes stretch4 {
25% {
transform: translateX(-50%) rotate(-2deg) scaleY(1.05);
}
50% {
transform: translateX(-50%) rotate(2deg) scaleY(0.93) scaleX(1.06);
clip-path: polygon(0% 40%, 100% 0%, 100% 99%, 19% 100%);
}
75% {
transform: translateX(-50%) rotate(3deg) scaleY(1.05);
clip-path: polygon(0% 40%, 100% 0%, 100% 99%, 19% 100%);
}
}
li:hover:after {
animation: boink 1s ease forwards 1;
}
#keyframes boink {
80% {
transform: scaleX(1.9) scaleY(0.6) translateX(-30%);
}
}
#media (max-width: 600px) {
li {
font-size: 15px;
}
}
This is external css file
What is wrong with external css file so I can't insert it properly ? Thank you.
I have been stucked with this code.
Thank you very much.
https://www.jqueryscript.net/slider/3D-Cube-Slider-jQuery-cubeGallery.html
When I insert cube, everything works as it should be. But not when I insert external css.
Thank you.

Why are my shapes flat after I added animation

I have a 3D triangle with a base color for every shape, but I want the base (aka the square) to have an animated color, but after adding the animation, the triangles all lay flat all of the sudden. When I remove the animation, the shapes readjust as they should.
For the animation I hue-rotate the linear-gradient color of the square in #keframes animate.
Here is the html code:
<div class="wrapper">
<div class="pyramid">
<div class="square">
<div class="triangle"></div>
<div class="triangle"></div>
<div class="triangle"></div>
<div class="triangle"></div>
</div>
</div>
</div>
And CSS:
#-webkit-keyframes animate {
0%, 100% {
filter: hue-rotate(0deg);
}
50% {
filter: hue-rotate(360deg);
}
}
#keyframes animate {
0%, 100% {
filter: hue-rotate(0deg);
}
50% {
filter: hue-rotate(360deg);
}
}
#-webkit-keyframes rotate {
from {
transform: rotateX(120deg) rotateZ(0deg);
}
50% {
transform: rotateX(120deg) rotateZ(180deg);
}
to {
transform: rotateX(120deg) rotateZ(360deg);
}
}
#keyframes rotate {
from {
transform: rotateX(120deg) rotateZ(0deg);
}
50% {
transform: rotateX(120deg) rotateZ(180deg);
}
to {
transform: rotateX(120deg) rotateZ(360deg);
}
}
.wrapper {
position: relative;
display: flex;
justify-content: center;
align-items: center;
top: 500px;
left: 50%;
margin-bottom: 0;
transform-style: preserve-3d;
width: 3.75rem;
height: 3.75rem;
transform-origin: 1.875rem 1.875rem;
transform: rotateX(120deg) rotateZ(45deg);
-webkit-animation: rotate 4s linear infinite;
animation: rotate 4s linear infinite;
}
.pyramid {
position: absolute;
perspective: 500px;
transform-style: preserve-3d;
}
.square {
width: 3.75rem;
height: 3.75rem;
transform-style: preserve-3d;
background: linear-gradient(to left, #008aff, #00ffe7);
-webkit-animation: animate 5s linear infinite;
animation: animate 5s linear infinite;
}
.triangle {
position: absolute;
width: 5rem;
height: 5rem;
}
.triangle:nth-child(1) {
width: 3.75rem;
top: -33%;
background: #f1ecfb;
-webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
transform-origin: 50% 100%;
transform: rotateX(-68deg);
}
.triangle:nth-child(2) {
width: 3.75rem;
background: #f1ecfb;
-webkit-clip-path: polygon(50% 100%, 0 0, 100% 0);
clip-path: polygon(50% 100%, 0 0, 100% 0);
transform-origin: 50% 0%;
transform: rotateX(68deg);
}
.triangle:nth-child(3) {
height: 3.75rem;
left: -33%;
background: white;
transform-origin: 100% 50%;
-webkit-clip-path: polygon(100% 100%, 0 50%, 100% 0);
clip-path: polygon(100% 100%, 0 50%, 100% 0);
transform: rotateY(68deg);
}
.triangle:nth-child(4) {
height: 3.75rem;
background: white;
transform-origin: 0% 50%;
-webkit-clip-path: polygon(0 100%, 100% 50%, 0 0);
clip-path: polygon(0 100%, 100% 50%, 0 0);
transform: rotateY(-68deg);
}
I changed it so that the animation changes the background color which resolves the issue.
#-webkit-keyframes animate {
0%, 100%{
background: #ffadad;
}
12.5%{
background: #ffd6a5;
}
25%{
background: #fdffb6;
}
37.5%{
background: #caffbf;
}
50%{
background: #9bf6ff;
}
62.5%{
background: #a0c4ff;
}
75%{
background: #bdb2ff;
}
87.5%{
background: #ffc6ff;
}
}
#keyframes animate {
0%, 100%{
background: #ffadad;
}
12.5%{
background: #ffd6a5;
}
25%{
background: #fdffb6;
}
37.5%{
background: #caffbf;
}
50%{
background: #9bf6ff;
}
62.5%{
background: #a0c4ff;
}
75%{
background: #bdb2ff;
}
87.5%{
background: #ffc6ff;
}
}

Firefox css spinner animation rendering issue

A spinner I want to use on my site looks bad on Firefox (48.0.2).
Comparison between Firefox and Chrome (imgur)
See the spinner live (Third spinner)
Is there a fix for this rendering issue?
Slowing the animation down didn't help so I'm turning to you guys (:D) and I don't think there is a fix for this yet on stackoverflow.
Here is code demonstrating the problematic spinner:
body {
background: #0dc5c1;
}
.loader {
font-size: 10px;
margin: 50px auto;
text-indent: -9999em;
width: 11em;
height: 11em;
border-radius: 50%;
background: #ffffff;
background: -moz-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -webkit-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -o-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -ms-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: linear-gradient(to right, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
position: relative;
-webkit-animation: load3 1.4s infinite linear;
animation: load3 1.4s infinite linear;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
}
.loader:before {
width: 50%;
height: 50%;
background: #ffffff;
border-radius: 100% 0 0 0;
position: absolute;
top: 0;
left: 0;
content: '';
}
.loader:after {
background: #0dc5c1;
width: 75%;
height: 75%;
border-radius: 50%;
content: '';
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
#-webkit-keyframes load3 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#keyframes load3 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
<div class="loader">Loading...</div>
Tested on Firefox, Chrome, Edge and IE(11). Only Firefox has problems.
body {
background: #0dc5c1;
}
.loader {
font-size: 10px;
margin: 50px auto;
/*text-indent: -9999em;*/
width: 11em;
height: 11em;
border-radius: 50%;
background: #ffffff;
background: -moz-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -webkit-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -o-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -ms-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: linear-gradient(to right, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
position: relative;
-webkit-animation: load 1.4s infinite linear;
animation: load 1.4s infinite linear;
/* -webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);*/
}
.loader:before {
width: 50%;
height: 50%;
background: #ffffff;
border-radius: 100% 0 0 0;
position: absolute;
top: 0;
left: 0;
content: '';
}
.loader:after {
background: #0dc5c1;
width: 75%;
height: 75%;
border-radius: 50%;
content: '';
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
#-webkit-keyframes load {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#keyframes load {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
<div class="loader"></div>

anchor tag doesn't work on an img in a animated div

So i'm working on a kind of solar system page. what i try to do is when a person clicks on a planet it redirects them to page. But for some reason it doesn't work. It's like the anchor doesn't exist. i tried to animate the anchor tag with the image but that doesn't seem to work.
THE HTML
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<!-- content to be placed inside <body>…</body> -->
<div id="one"><a id="aone" href="http://google.com"><img src="one.png"></a></div>
<div id="two"><img src="two.png"></div>
<div id="three"></div>
</body>
</html>
THE CSS
body{
position: absolute;
top: 50%; left: 50%;
margin: -150px;
border: dashed 1px;
width: 300px; height: 300px;
border-radius: 50%;
content: '';
}
#one {
text-align: center;
position: absolute;
top: 50%; left: 50%;
margin: -25px;
width: 50px; height: 50px;
animation: rot1 8s infinite linear;
-webkit-animation: rot1 8s infinite linear;
}
#-webkit-keyframes rot1 {
0% { -webkit-transform: rotate(0deg) translate(300px) rotate(0deg); }
100% { -webkit-transform: rotate(360deg) translate(300px) rotate(-360deg); }
}
#keyframes rot1 {
0% { transform: rotate(0deg) translate(300px) rotate(0deg); }
100% { transform: rotate(360deg) translate(300px) rotate(-360deg); }
}
#two {
text-align: center;
position: absolute;
top: 50%; left: 50%;
margin: -25px;
width: 50px; height: 50px;
transparent 49%, black 49%, black 51%, transparent 51%);
animation: rot2 34s infinite linear;
-webkit-animation: rot2 34s infinite linear;
}
#-webkit-keyframes rot2 {
0% { -webkit-transform: rotate(0deg) translate(150px) rotate(0deg); }
100% { -webkit-transform: rotate(360deg) translate(150px) rotate(-360deg); }
}
#keyframes rot2 {
0% { transform: rotate(0deg) translate(150px) rotate(0deg); }
100% { transform: rotate(360deg) translate(300px) rotate(-360deg); }
}
#three {
text-align: center;
position: absolute;
top: 50%; left: 50%;
margin: -25px;
width: 50px; height: 50px;
background:
linear-gradient(transparent 49%, black 49%, black 51%, transparent 51%),
rgba(0,0,255,.3) linear-gradient(90deg,
transparent 49%, black 49%, black 51%, transparent 51%);
animation: rot3 34s infinite linear;
-webkit-animation: rot3 34s infinite linear;
}
#-webkit-keyframes rot3 {
0% { -webkit-transform: rotate(0deg) translate(50px) rotate(0deg); }
100% { -webkit-transform: rotate(360deg) translate(50px) rotate(-360deg); }
}
#keyframes rot3 {
0% { transform: rotate(0deg) translate(50px) rotate(0deg); }
100% { transform: rotate(360deg) translate(50px) rotate(-360deg); }
}
http://jsfiddle.net/DJsU9/
I don't know if it's possible to move the real anchor position (not just the graphics position) using the CSS transform property but there's an incredibly easy solution for this question without the use of javascript:
You can create three invisible circles, put links on each one and then position them over the existing animation. This method is good because even if the user clicks in the wrong position the link will work.
Note that I've colored the circles with transparent red, but you can (and should) remove the color by deleting the background:rgba(255,0,0,0.5); lines.
Here's the relevant CSS:
.circle1{
display:block;
position:absolute;
top:50%;
margin-top:-325px;
left:50%;
margin-left:-325px;
width:650px;
height:650px;
background:rgba(255,0,0,0.5); /* unnecessary */
border-radius:100%;
}
.circle2{
display:block;
position:absolute;
top:50%;
margin-top:-175px;
left:50%;
margin-left:-175px;
width:350px;
height:350px;
background:rgba(255,0,0,0.5); /* unnecessary */
border-radius:100%;
}
HTML:
<div id="one"><a id="aone" href="http://google.com"><img src="http://dedobbelaere.sisamul.com/one.png"></a>
</div>
<div id="two"><a id="aone" href="http://google.com"><img src="http://dedobbelaere.sisamul.com/two.png"></a>
</div>
<div id="three"></div>
<a class="circle1" href="http://dedobbelaere.sisamul.com/two.png"></div>
<a class="circle2" href="http://google.com"></div>
JSFiddle
Only corrected sintax on nested html element, tested on IE10 and Chrome35(Windows 8 Pro), but probably you need to fix some platform/cross-browser issue.
Anyway you should set an unique id to your hyperlinks
http://jsfiddle.net/InferOn/DJsU9/11/
HTML
<div id="one">
<a id="aone" target="_blank" href="http://google.com">
<img src="http://dedobbelaere.sisamul.com/one.png"/>
</a>
</div>
<div id="two">
<a id="aone" target="_blank" href="http://google.com">
<img src="http://dedobbelaere.sisamul.com/two.png"/>
</a>
</div>
<div id="three"></div>
CSS
/**
* Prevent an element to rotate itself in a circular CSS3 animation
* http://stackoverflow.com/q/14057780/1397351
*/
a {
border: 1px solid red;
}
body {
position: absolute;
top: 50%;
left: 50%;
margin: -150px;
border: dashed 1px;
width: 300px;
height: 300px;
border-radius: 50%;
content:'';
}
#one {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
margin: -25px;
width: 50px;
height: 50px;
animation: rot1 8s infinite linear;
-webkit-animation: rot1 8s infinite linear;
}
#-webkit-keyframes rot1 {
0% {
-webkit-transform: rotate(0deg) translate(300px) rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg) translate(300px) rotate(-360deg);
}
}
#keyframes rot1 {
0% {
transform: rotate(0deg) translate(300px) rotate(0deg);
}
100% {
transform: rotate(360deg) translate(300px) rotate(-360deg);
}
}
#two {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
margin: -25px;
width: 50px;
height: 50px;
transparent 49%, black 49%, black 51%, transparent 51%);
animation: rot2 34s infinite linear;
-webkit-animation: rot2 34s infinite linear;
}
#-webkit-keyframes rot2 {
0% {
-webkit-transform: rotate(0deg) translate(150px) rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg) translate(150px) rotate(-360deg);
}
}
#keyframes rot2 {
0% {
transform: rotate(0deg) translate(150px) rotate(0deg);
}
100% {
transform: rotate(360deg) translate(300px) rotate(-360deg);
}
}
#three {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
margin: -25px;
width: 50px;
height: 50px;
background: linear-gradient(transparent 49%, black 49%, black 51%, transparent 51%), rgba(0, 0, 255, .3) linear-gradient(90deg, transparent 49%, black 49%, black 51%, transparent 51%);
animation: rot3 34s infinite linear;
-webkit-animation: rot3 34s infinite linear;
}
#-webkit-keyframes rot3 {
0% {
-webkit-transform: rotate(0deg) translate(50px) rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg) translate(50px) rotate(-360deg);
}
}
#keyframes rot3 {
0% {
transform: rotate(0deg) translate(50px) rotate(0deg);
}
100% {
transform: rotate(360deg) translate(50px) rotate(-360deg);
}
}