I'm creating a CSS3 loading icon effect instead of using GIF. I have created the loading icon effect but I'm unable to make it circle. It is revolving in square instead of circle. Border-radius not working with border-image property ?
HTML
<div id="progress">
<span class="spinner-icon"></span>
</div>
CSS
#progress {
pointer-events: none;
}
#progress .spinner-icon {
width: 30px;
height: 30px;
display:block;
border: solid 2px transparent;
border-radius:50%;
-webkit-animation: progress-spinner 600ms linear infinite;
animation: progress-spinner 600ms linear infinite;
-moz-border-image: -moz-linear-gradient(top, #3acfd5 0%, #3a4ed5 100%);
-webkit-border-image: -webkit-linear-gradient(top, #3acfd5 0%, #3a4ed5 100%);
border-image: linear-gradient(to bottom, #3acfd5 0%, #3a4ed5 100%);
border-image-slice: 1;
}
#progress {
position: absolute;
}
#-webkit-keyframes progress-spinner {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
#keyframes progress-spinner {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
http://jsfiddle.net/44athund/3/
This won't work with border-image. The radius is being applied to the object however the border-image with a gradient will not be respected.
Based on what you what, I've created a fiddle here https://jsfiddle.net/a9dpg582/1/ I think this is what you're after.
#progress {
pointer-events: none;
position: relative;
}
#progress .spinner-icon::after {
content: '';
border-radius: 50%;
background-color: #FFF;
width: 26px;
height: 26px;
position: absolute;
left: 2px;
top: 2px;
}
#progress .spinner-icon {
width: 30px;
height: 30px;
display: block;
background-image: -webkit-linear-gradient(top, #3acfd5 0%, #3a4ed5 100%);
border-radius: 50%;
-webkit-animation: progress-spinner 600ms linear infinite;
animation: progress-spinner 600ms linear infinite;
}
#progress {
position: absolute;
border-radius: 50%;
}
#-webkit-keyframes progress-spinner {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
#keyframes progress-spinner {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
Related
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;
}
}
I have a problem, I made a beautiful button with snake effect but I need a last thing, I need to hide overflow to make the snake effect.
there is my button:
I want to hide theses parts, with overflow: hidden; this works with position: absolute; but not with relative.
body {
padding: 30px;
}
.btn-order {
position: relative;;
background-color: #961a22;
color: #ff7675;
padding: 30px 60px;
font-family: Helvetica;
font-size: 30px;
font-weight: 400;
letter-spacing: 2px;
text-transform: uppercase;
text-decoration: none;
box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
overflow: hidden;
}
.btn-order:before {
content: '';
position: absolute;
top: 0px;
left: 0px;
bottom: 0px;
width: 50%;
background: rgba(255, 255, 255, 0.07);
}
.btn-order span:nth-child(1) {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 4px;
background: linear-gradient(to right, #ffffff, #ff3a3a);
animation: animate1 1.25s linear infinite;
}
#keyframes animate1 {
0% {
transform: translateX(-100%);
}
100% {
transform: translateX(100%);
}
}
.btn-order span:nth-child(2) {
position: absolute;
top: 0;
right: 0;
width: 4px;
height: 100%;
background: linear-gradient(to bottom, #ffffff, #ff3a3a);
animation: animate2 1.25s linear infinite;
animation-delay: 0.625s;
}
#keyframes animate2 {
0% {
transform: translateY(-100%);
}
100% {
transform: translateY(100%);
}
}
.btn-order span:nth-child(3) {
position: absolute;
bottom: 0;
right: 0;
width: 100%;
height: 4px;
background: linear-gradient(to left, #ffffff, #ff3a3a);
animation: animate3 1.25s linear infinite;
}
#keyframes animate3 {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(-100%);
}
}
.btn-order span:nth-child(4) {
position: absolute;
top: 0;
left: 0;
width: 4px;
height: 100%;
background: linear-gradient(to top, #ffffff, #ff3a3a);
animation: animate4 1.25s linear infinite;
animation-delay: 0.625s;
}
#keyframes animate4 {
0% {
transform: translateY(100%);
}
100% {
transform: translateY(-100%);
}
}
<a href="#" class="btn-order">
<span></span>
<span></span>
<span></span>
<span></span>
COMMANDER
</a>
Thanks for helping me :)
Increasing the body width can fix it.
in this code snippet i have simple background for my container and i put a radial pattern on it i want to use half of transparent pattern and have animation and my problem is how can i use just half of the radial pattern correctly
like this :
css:
.container {
width: 600px;
height: 600px;
position: relative;
margin: 0 auto;
overflow: hidden;
background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHJhZGlhbEdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9IjUwJSIgY3k9IjUwJSIgcj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzI4YTlkZCIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzBkNGU3NyIvPjwvcmFkaWFsR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==');
background: -moz-radial-gradient(#28a9dd, #0d4e77);
background: -webkit-radial-gradient(#28a9dd, #0d4e77);
background: radial-gradient(#28a9dd, #0d4e77);
}
.container:after {
content: "";
display: block;
position: absolute;
width: 850px;
height: 850px;
top: -125px;
left: -125px;
background: url(http://static.puzzlexperts.com/images/RadialBurst_bkgd.png) no-repeat top center, url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHJhZGlhbEdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9IjUwJSIgY3k9IjUwJSIgcj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzI4YTlkZCIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzBkNGU3NyIvPjwvcmFkaWFsR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==');
background: url(http://static.puzzlexperts.com/images/RadialBurst_bkgd.png) no-repeat top center, -moz-radial-gradient(#28a9dd, #0d4e77);
background: url(http://static.puzzlexperts.com/images/RadialBurst_bkgd.png) no-repeat top center, -webkit-radial-gradient(#28a9dd, #0d4e77);
background: url(http://static.puzzlexperts.com/images/RadialBurst_bkgd.png) no-repeat top center, radial-gradient(#28a9dd, #0d4e77);
background-position: center;
background-blend-mode: screen;
-moz-animation: spin 20s linear infinite;
-webkit-animation: spin 20s linear infinite;
animation: spin 20s linear infinite;
}
#-moz-keyframes spin {
0% {
-moz-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(300deg);
transform: rotate(300deg);
}
}
#-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(300deg);
transform: rotate(300deg);
}
}
#keyframes spin {
0% {
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(300deg);
-ms-transform: rotate(300deg);
-webkit-transform: rotate(300deg);
transform: rotate(300deg);
}
}
HTML:
<div class="container"></div>
https://codepen.io/flurrd/pen/gbYZGb
You need to resize the pseudo element (.container::after) to be more than twice as large as the container (4 times is easier to use), and set the rotation point to be around the base of the container. In addition, you need to resize the image to fit the new size of the pseudo-element (using background size).
Demo (pen)
.container {
width: 600px;
height: 600px;
position: relative;
margin: 0 auto;
overflow: hidden;
}
.container:after {
content: "";
display: block;
position: absolute;
width: 2400px;
height: 2400px;
top: -90%;
left: -150%;
background: url(http://static.puzzlexperts.com/images/RadialBurst_bkgd.png) no-repeat top center, radial-gradient(#28a9dd, #0d4e77);
background-position: center;
background-size: 2400px;
background-blend-mode: screen;
animation: spin 20s linear infinite;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div class="container"></div>
Can you add something like this:
background: radial-gradient(rgba(0, 0, 0, 0)0%, rgba(0, 0, 0, 0)30%, #e66465 30%, #9198e5);
You can specify a percentage to remain transparent, in this case the radial gradient would be transparent to 30%, then from 30% a color.
You can just add this as an overlay and keep your other image behind...
I'm trying to convert this button in responsive but i don't know how, i want this 4 button display verticaly aligned only on mobile. I didn't find any site for this problem :(. Thank you for all the answer!
.rainbow {
position: absolute;
top: -3px;
right: -3px;
bottom: -3px;
left: -3px;
z-index: 1;
background: linear-gradient(124deg, #ff2400, #e81d1d, #e8b71d, #e3e81d, #1de840, #1ddde8, #2b1de8, #dd00f3, #dd00f3);
background-size: 1800% 1800%;
-webkit-animation: rainbow 7s ease infinite;
-z-animation: rainbow 7s ease infinite;
-o-animation: rainbow 7s ease infinite;
animation: rainbow 7s ease infinite;
mix-blend-mode: screen;
}
.bottoni {
float: center;
margin: 0 auto;
text-align: center;
margin-top: 7%;
}
.bottone {
display: inline-block;
position: relative;
padding-top: 17px;
text-align: center;
font-family: sans-serif;
width: 100% auto;
font-weight: bold;
margin-right: 20px;
margin-left: 20px;
text-transform: uppercase;
width: 200px;
height: 35px;
border: 3px solid black;
background: white;
transform: 1s;
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px transparent;
position: relative;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-property: transform;
transition-property: transform;
-webkit-animation: bottoni 1s ease 0s 1 normal ;
animation: bottoni 1s ease 0s 1 normal ;
}
.bottone:before {
pointer-events: none;
position: absolute;
z-index: -1;
content: '';
top: 100%;
left: 5%;
height: 10px;
width: 90%;
opacity: 0;
background: -webkit-radial-gradient(center, ellipse, rgba(0, 0, 0, 0.35) 0%, transparent 80%);
background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.35) 0%, transparent 80%);
/* W3C */
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-property: transform, opacity;
transition-property: transform, opacity;
}
.bottone:hover, .bottone:focus, .bottone:active {
cursor: pointer;
-webkit-transform: translateY(-10px);
transform: translateY(-10px);
}
.bottone:hover:before, .bottone:focus:before, .bottone:active:before {
opacity: 1;
-webkit-transform: translateY(10px);
transform: translateY(10px);
}
/* Animation */
#-webkit-keyframes rainbow {
0% {
background-position: 0% 82%
}
50% {
background-position: 100% 19%
}
100% {
background-position: 0% 82%
}
}
#-moz-keyframes rainbow {
0% {
background-position: 0% 82%
}
50% {
background-position: 100% 19%
}
100% {
background-position: 0% 82%
}
}
#-o-keyframes rainbow {
0% {
background-position: 0% 82%
}
50% {
background-position: 100% 19%
}
100% {
background-position: 0% 82%
}
}
#keyframes rainbow {
0% {
background-position: 0% 82%
}
50% {
background-position: 100% 19%
}
100% {
background-position: 0% 82%
}
}
<div class="bottoni">
<a class="bottone">
Votaci
<div class="rainbow"></div>
</a>
<a class="bottone">
forum
<div class="rainbow"></div>
</a>
<a class="bottone">
regolamento
<div class="rainbow"></div>
</a>
<a class="bottone">
shop
<div class="rainbow"></div>
</a>
</div>
All answer are apprecited
You could use absolute position on mobile on .bottoni to center your menu verticaly, for the responsive use media queries :
#media (max-width: 480px) {
.bottoni {
top: 50%; /* adjust to your needs */
position: absolute;
left: 0;
right: 0;
}
}
see the : https://jsfiddle.net/s0smLw16/
Try adding a #media selector to your css.
#media screen and (max-width: 1000px) {
a.btn {
display: block;
}
}
Example: https://jsfiddle.net/qpe2xoem/1/
.rainbow {
position: absolute;
top: -3px;
right: -3px;
bottom: -3px;
left: -3px;
z-index: 1;
background: linear-gradient(124deg, #ff2400, #e81d1d, #e8b71d, #e3e81d, #1de840, #1ddde8, #2b1de8, #dd00f3, #dd00f3);
background-size: 1800% 1800%;
-webkit-animation: rainbow 7s ease infinite;
-z-animation: rainbow 7s ease infinite;
-o-animation: rainbow 7s ease infinite;
animation: rainbow 7s ease infinite;
mix-blend-mode: screen;
}
.bottoni {
float: center;
margin: 0 auto;
text-align: center;
margin-top: 7%;
}
.bottone {
display: inline-block;
position: relative;
padding-top: 17px;
text-align: center;
font-family: sans-serif;
width: 100% auto;
font-weight: bold;
margin-right: 20px;
margin-left: 20px;
text-transform: uppercase;
width: 200px;
height: 35px;
border: 3px solid black;
background: white;
transform: 1s;
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px transparent;
position: relative;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-property: transform;
transition-property: transform;
-webkit-animation: bottoni 1s ease 0s 1 normal ;
animation: bottoni 1s ease 0s 1 normal ;
}
.bottone:before {
pointer-events: none;
position: absolute;
z-index: -1;
content: '';
top: 100%;
left: 5%;
height: 10px;
width: 90%;
opacity: 0;
background: -webkit-radial-gradient(center, ellipse, rgba(0, 0, 0, 0.35) 0%, transparent 80%);
background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.35) 0%, transparent 80%);
/* W3C */
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-property: transform, opacity;
transition-property: transform, opacity;
}
.bottone:hover, .bottone:focus, .bottone:active {
cursor: pointer;
-webkit-transform: translateY(-10px);
transform: translateY(-10px);
}
.bottone:hover:before, .bottone:focus:before, .bottone:active:before {
opacity: 1;
-webkit-transform: translateY(10px);
transform: translateY(10px);
}
/* Animation */
#-webkit-keyframes rainbow {
0% {
background-position: 0% 82%
}
50% {
background-position: 100% 19%
}
100% {
background-position: 0% 82%
}
}
#-moz-keyframes rainbow {
0% {
background-position: 0% 82%
}
50% {
background-position: 100% 19%
}
100% {
background-position: 0% 82%
}
}
#-o-keyframes rainbow {
0% {
background-position: 0% 82%
}
50% {
background-position: 100% 19%
}
100% {
background-position: 0% 82%
}
}
#keyframes rainbow {
0% {
background-position: 0% 82%
}
50% {
background-position: 100% 19%
}
100% {
background-position: 0% 82%
}
}
#media only screen and (min-width: 480px) {
.bottoni {
top: 50%; /* adjust to your needs */
position: absolute;
left: 0;
right: 0;
}
}
<div class="bottoni">
<a class="bottone">
Votaci
<div class="rainbow"></div>
</a>
<a class="bottone">
forum
<div class="rainbow"></div>
</a>
<a class="bottone">
regolamento
<div class="rainbow"></div>
</a>
<a class="bottone">
shop
<div class="rainbow"></div>
</a>
</div>
you can use css #media
#media screen and (min-width: 480px // size of the screen) {}
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);
}
}