Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 1.41 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <div class="wrapper">
  2.         <h1>Maintaining CSS Style States using "Infinite" Transition Delays</h1>
  3.        
  4.         <div class="device">
  5.                 <button class="up"></button>
  6.                 <button class="down"></button>
  7.                 <button class="left"></buton>
  8.                 <button class="right"></button>
  9.        
  10.                 <div class="screen">
  11.                         <div class="char"></div>
  12.                         <div class="overlay"></div>
  13.                 </div>
  14.         </div>
  15.        
  16.         <section>
  17.         <p>
  18.                 This demo is <strong>completely JavaScript-free</strong>.
  19.                 Feel free to move the character around with the D-pad, and notice how it always
  20.                 keeps its position after you stop moving.
  21.         </p>
  22.         <p>
  23.                 This is made possible by using a virtually infinite transition delay, so that the
  24.                 CSS rules never return to their default state. The character will always be stuck
  25.                 in a transition and only moves when you hold down a button.
  26.         </p>
  27.        
  28.         <p>
  29.                 I've written a
  30.         <a target="_blank" href="http://joelb.me/blog/2012/maintaining-css-style-states-using-infinite-transition-delays/"> blog post </a> explanining how
  31.                 this all works, but please keep in mind that things like this should ideally be handled
  32.                 with Javascript. After all, this is a dirty hack, not a CSS feature.
  33.         </p>
  34.         </section>
  35.        
  36.         <small>Credit goes to to <a target="_blank" href="http://www.tekepon.net/fsm/">First Seed Material</a> for the
  37.         character sprite, and <a target="_blank" href="http://vxresource.wordpress.com/2010/03/17/the-real-macks-tileset/">
  38.         Mack</a> for the map tileset.
  39.          </small>
  40. </div>