Based on http://davidwalsh.name/css-flip (non IE version).