Created
August 19, 2012 06:30
-
-
Save LeaVerou/3392707 to your computer and use it in GitHub Desktop.
Hexagon kitty - By @LeaVerou
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
/* Hexagon kitty - By @LeaVerou | |
Disappointingly inflexible, but still interesting methinks. | |
*/ | |
.hexagon { | |
display: inline-block; | |
position: relative; | |
width: 200px; | |
height: 200px; | |
transform: scale(1.25,.707) rotate(-45deg); | |
overflow: hidden; | |
backface-visibility: hidden; /* hack to make it smoother, suggested by Mottie */ | |
} | |
.hexagon > img { | |
position: absolute; | |
transform: rotate(45deg) scale(.8, 1.404); | |
clip: rect(0,187px,200px,13px); | |
} |
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
<img src="http://placekitten.com/200/200" /> | |
<div class="hexagon"><img src="http://placekitten.com/200/200" /></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":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"} |
If you add -webkit-backface-visibility: hidden;
to the .hexagon
definition, the edges smooth out much more nicely.
Thanks Mottie, done!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reminds me @kizu's experiments: http://kizu.github.com/Polygons/