Skip to content

Instantly share code, notes, and snippets.

@opi
Created August 14, 2014 19:29
Show Gist options
  • Save opi/9408c9f03b1400f8c4df to your computer and use it in GitHub Desktop.
Save opi/9408c9f03b1400f8c4df to your computer and use it in GitHub Desktop.
I call it art
// Generate a random DOM.
// http://twitter.com/cowboy/status/65845594400362496
(function(s,n){while(n--){s.push($('<div/>').appendTo(s[~~(Math.random()*(s.length-1))]))}})(['body'],10000);
// Cycle bg, starting at a random color.
(function(time){
var start = Math.floor(Math.random() * time);
var dec = "animation: bgcolors -" + start + "s " + time + "s linear infinite;";
var html = "<style>html{-webkit-" + dec + dec + "}</style>";
$("head").append(html);
}(180));g
// Ping-pong scroll animation. starting at a random position.
(function(time){
var start = Math.floor(Math.random() * time);
var top = $(window).height() - $(document).height();
var dec = "animation: scroll -" + start + "s " + time + "s linear infinite;"
var kf = "keyframes scroll { 0%,100% {top: 0;} 50% {top: " + top + "px;} }";
var html = "<style>body{-webkit-" + dec + dec + "}@-webkit-" + kf + "@" + kf + "</style>";
$("head").append(html);
}(5000));
// Click to reload animation.
$(document).on("click", function() {
location.href = location.href;
});
body {
margin: 2px;
padding: 0;
overflow: hidden;
position: relative;
}
div {
border: 10px solid rgba(0, 0, 0, 0.5);
margin: 0 2px 2px 0;
padding: 2px 0 0 2px;
display: inline-block;
text-align: center;
line-height: 0;
}
/* Generated via
http://jsfiddle.net/cowboy/wsw0rmeh/show/
https://twitter.com/cowboy/status/499972839723003904 */
@-webkit-keyframes bgcolors {
0%,100% { background: hsl(0, 90%, 60%); }
10% { background: hsl(36, 90%, 60%); }
20% { background: hsl(72, 90%, 60%); }
30% { background: hsl(108, 90%, 60%); }
40% { background: hsl(144, 90%, 60%); }
50% { background: hsl(180, 90%, 60%); }
60% { background: hsl(216, 90%, 60%); }
70% { background: hsl(252, 90%, 60%); }
80% { background: hsl(288, 90%, 60%); }
90% { background: hsl(324, 90%, 60%); }
}
@keyframes bgcolors {
0%,100% { background: hsl(0, 90%, 60%); }
10% { background: hsl(36, 90%, 60%); }
20% { background: hsl(72, 90%, 60%); }
30% { background: hsl(108, 90%, 60%); }
40% { background: hsl(144, 90%, 60%); }
50% { background: hsl(180, 90%, 60%); }
60% { background: hsl(216, 90%, 60%); }
70% { background: hsl(252, 90%, 60%); }
80% { background: hsl(288, 90%, 60%); }
90% { background: hsl(324, 90%, 60%); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment