Hacker News new | past | comments | ask | show | jobs | submit login

Calling it Donuts.css kind of implies its done in CSS exclusively.



Yeah, I wish people would stop doing this, especially since almost every example posted here is also tightly coupled to jQuery. It's a cool widget though.

It would be interesting if you could use `calc` and `attr` to do this purely with CSS, but it doesn't seem to be that flexible yet. Ie:

   transform: rotate(attr(data-percentage) "deg")
EDIT: Heh, actually, as a Dojo/Python/LESS fan, I'm really not the target for that project! =D


Looking at the code, the design is mostly done in CSS: the obvious border-radius for the circles, :before pseudo-classes for the origin, and rotate transformations along with transitions for the animated arrow. Circle sizes are based upon the css subclass.

The jQuery only sets the colors and the arrows' angle.


Having a tiny bit of JS and having no JS at all is worlds apart. I edited the DOM in my inspector to try to add arrows and change percentages, but nothing happened after I injected new elements.

Had this been entirely in CSS, it would have automatically rendered immediately after modifying the DOM.


It's not really possible to do what you want to do (at least not without generating a CSS rule for every possible percentage value), but you can get damn close by calculating the right rotation (apparently "percent * 1.8 - 90") and setting the "transform" properties yourself.

EDIT: here's a "pure CSS" version: http://codepen.io/tlrobinson/pen/aGvrF




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: