Skip to content

Instantly share code, notes, and snippets.

@madrobby
Created April 21, 2011 08:47
Show Gist options
  • Save madrobby/934008 to your computer and use it in GitHub Desktop.
Save madrobby/934008 to your computer and use it in GitHub Desktop.
// tweet-sized, and does (approximately) the same thing
var t=document.all,l=t.length,w='-webkit-trans';while(l--)t[l].style.cssText+=w+'ition:all,20s;'+w+'form:rotate('+Math.random()+'rad)'
@stdclass
Copy link

w="-webkit-trans";i=0;while(e=document.querySelectorAll("div")[i++])e.style.cssText+=w+"ition:20s;"+w+"form:rotate("+i/10+"rad)"

@dave1010
Copy link

109: like @joside's but with * instead of div

s='-webkit-trans';document.styleSheets[1].addRule('*',s+'ition:20s;'+s+'form:rotate('+Math.random()+'rad)')

Edit:

Not sure where the 20s came from but 9s looks just as good:

s='-webkit-trans';document.styleSheets[1].addRule('*',s+'ition:9s;'+s+'form:rotate('+Math.random()+'rad)')

@marcheiligers
Copy link

I think @joside has won this game.

@sebastien-p
Copy link

@marcheiligers : what if there is actually not any document.styleSheets ?

@dave1010
Copy link

Should be able to get it to work in Opera with '-o-trans', which would shave 5 chars but I can't get it to work :-(. Means you loose 1% of browser market share though.

@jdalton
Copy link

jdalton commented Apr 21, 2011

[].map.call(document.all,function(e,s){s='-webkit-trans';e.style.cssText+=s+'ition:20s;'+s+'form:rotate('+Math.random()+'rad)'})

@vladocar
Copy link

Array.prototype.slice.call(document.all).forEach(function(e,s){s='-webkit-trans';e.style.cssText+=s+'ition:20s;'+s+'form:rotate('+Math.random()+'rad)'})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment