Skip to content

Instantly share code, notes, and snippets.

@benvium
Created August 17, 2012 09:57
Show Gist options
  • Save benvium/3377598 to your computer and use it in GitHub Desktop.
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.
<!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>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment