Created
August 17, 2012 09:57
-
-
Save benvium/3377598 to your computer and use it in GitHub Desktop.
A Pure CSS3 Kaleidoscope. Demonstrates using a mask image defined using SVG, and CSS3 transforms.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<style> | |
.slice { | |
background-image: url(http://upload.wikimedia.org/wikipedia/commons/8/89/Swiss_cheese_cubes.jpg); | |
position: absolute; | |
left: 0; | |
top: 0; | |
width: 500px; | |
height: 500px; | |
background-position-x: 0; | |
background-position-y: 0; | |
-webkit-mask-image: url(tri.svg); | |
-webkit-transform-origin: 100% 100%; | |
-webkit-transition:background-position-x 2s; | |
} | |
#slice2 { | |
-webkit-transform: scaleX(-1); | |
} | |
#slice3 { | |
-webkit-transform: rotate(90deg); | |
} | |
#slice4 { | |
-webkit-transform: scaleX(-1) rotate(90deg); | |
} | |
#slice5 { | |
-webkit-transform: scaleY(-1) rotate(90deg); | |
} | |
#slice6 { | |
-webkit-transform: scaleX(-1) scaleY(-1); | |
} | |
#slice7 { | |
-webkit-transform: scaleY(-1); | |
} | |
#slice8 { | |
-webkit-transform: scaleY(-1) scaleX(-1) rotate(90deg) | |
} | |
</style> | |
<script> | |
var x = 0; | |
var y = 0; | |
$(document).ready(function () { | |
startAnim("100%"); | |
}); | |
function startAnim(f) { | |
$(".slice").css({ | |
"background-position-x":f | |
}); | |
setTimeout(function () { | |
startAnim(f === "100%" ? "0%" : "100%"); | |
},3000); | |
} | |
</script> | |
</head> | |
<body> | |
<div id="kal" style="width:1000px; height:1000px"> | |
<div class="slice" id="slice1"></div> | |
<div class="slice" id="slice2"></div> | |
<div class="slice" id="slice3"></div> | |
<div class="slice" id="slice4"></div> | |
<div class="slice" id="slice5"></div> | |
<div class="slice" id="slice6"></div> | |
<div class="slice" id="slice7"></div> | |
<div class="slice" id="slice8"></div> | |
</div> | |
</body> | |
</html> |
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
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"> | |
<polygon points="0,0 500,0 500,500" style="fill:gray" /> | |
</svg> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment