Created
March 28, 2012 10:37
-
-
Save sakamies/2225318 to your computer and use it in GitHub Desktop.
Pixel Perfect CSS Rotation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Pixel Perfect CSS Rotation */ | |
body { | |
text-align: center; | |
} | |
.clock { | |
display: inline-block; | |
background: black; | |
border-radius: 100%; | |
width: 101px; | |
height: 101px; | |
position: relative; | |
} | |
.hand { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
width: 40px; | |
height: 1px; | |
background: red; | |
transition: all .5s ease; | |
transform-origin: left center; | |
} | |
.sharp.hand { | |
transform-origin: 1.25% 50%; /* 0.5/40*100 */ | |
/* Set the origin exactly to the center of | |
the first pixel from the left */ | |
} | |
.clock:hover .hand { | |
background: white; | |
transform: rotateZ(90deg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<small>Hover clocks to rotate the hand 90 degrees.</small> | |
<h3>Blurry clock hand</h3> | |
<div class="clock"> | |
<div class="hand"> </div> | |
</div> | |
<h3>Sharp clock hand</h3> | |
<div class="clock"> | |
<div class="sharp hand"> </div> | |
</div> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"view":"separate","seethrough":"","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment