Stopwatch with only CSS3 - No javascript
thecodeplayer.com
thecodeplayer.com
<!-- Lets load up prefixfree first -->
<script src="http://thecodeplayer.com/uploads/js/prefixfree.js" type="text/javascript"></script>
<!-- You can download it from http://leaverou.github.com/prefixfree/ -->
Granted all it does is add the vendor based prefixes to certain CSS3 attributes, but this particular demo does in fact use Javascript.How so? You both are right. It uses javascript (as parent said) but doesnt use javascript to the animation (as you said).
This nitpicking is ruining the internet commenting for me. And yes, I see the irony in my comment.
Safari > Develop > Disable Styles
Opera > View > Style > User Mode
It doesn't look like Chrome has an option by default, and I don't have IE on hand to test.
javascript:var%20i=0;if(document.styleSheets.length>0){cs=!document.styleSheets[0].disabled;for(i=0;i<document.styleSheets.length;i++)%20document.styleSheets[i].disabled=cs;};void(cs=true);But it's not very usable as a stopwatch.
A real stopwatch has a single start/stop button that triggers when pressed.
This stopwatch has separate mouse-driven buttons for start and stop, and they trigger when released. That makes it impossible to measure a very short time, and awkward to start and stop at precise moments.
It would also be nice if there were keyboard shortcuts for stop/start/reset - and those keyboard shortcuts should also trigger on keydown. (You could make a minor improvement on physical stopwatches by supporting both a single key for stop/start and two separate keys. The single key is convenient and familiar, but being able to use separate keys would make it easy to time very short events. This of course works only with the keyboard and not with mouse-driven buttons.)
Can all that be done in CSS? I suspect not - and if not, then why go to extra work to achieve a pure CSS implementation that's less usable? You could do it more easily with JavaScript, make it compatible with more browsers, and provide a better user experience too.
But I'm fairly certain that not everybody understands the limitations I mentioned. You and I and hopefully most of the folks here, sure. But spend some time on the css-discuss mailing list [1] for an eye-opener.
Many of the members of that list seem to favor CSS-only solutions even when the user experience is inferior to what you could achieve with a sensible blend of CSS and JavaScript. And they're not just talking demos, they put this stuff into production.
I don't understand that point of view at all. I want the best solution for the user, and I'll use whatever tools are necessary to build it.
Even so I think it is a great proof of concept and the font style was cool idea.
The problem I see, it that at one point you my start using CSS for something that will eventually (without you prior knowledge) grow bigger and more complex outside of the realms/possiblilies of CSS, now you will have to re-write.
Call me a purist, but when you start using CSS for more that styling, you might want to re-evaluate.
That said, again, I think this example is awesome for showing the new feature of the CSS language.
> The JS used is prefixfree - just to make the length and size of the tutorial short and easy. No images or JS are used in the stopwatch logic/display.
It would be trivial to make a new -really- JS free version, but it wouldn't be so easy to understand. It could be non-js in production, it just isn't for teaching purposes, so I am happy to accept it as a 'non-js' stopwatch.
The alternative is to pay what might seem like a ton of money for something that they aren't going to need 364 days out of the year.
Perhaps somebody could deploy to their host?
Back up! Seeing what people do with CSS is like watching MacGyver - it might be the wrong tool for the job but it's always impressive. Look, I built a gun with some rubber tubing, a rotten egg, and a duck!