A "Wheel of Fortune" component just popped up in my feed. I always spin, but never win! Anyway, this type of component is often built with <canv...
For further actions, you may consider blocking this person and/or reporting abuse
The height calculation is actually not correct. You need to consider the polygon shape around the circle to find the correct height (the circumscribed polygon)
It's equal to
height: calc(2*50cqi*tan(180deg/var(--_items)));
that you can simplify by setting the ratioaspect-ratio: 1/calc(2*tan(180deg/var(--_items)));
to avoid using the width value twice.With this you won't have issue when you apply the clip-path
AH, perfect — thank you! You truly are the master of CSS Shapes. I've added an update, and will use your input for the follow-up article with spinning.
I really like your implementation because all libs create a wheel using canvas but i need the one to be highly customizable. Please help me to add logic to spin the wheel to the predefined (from backend or mocked) sector!
You just need to set
newEndDegree
manually, matching your predefined destination.Has anyone solved the return value of the winning field? For example index for li tag. I have something, but the results are +- one position.
I think it’s resolved ( Link on Codepen.io ).
Cool!
Please share — I need to think about it too!
Always here for an interesting CSS project. Kudos.
Thanks!
wholesome wheel! :)
Beautiful project!
Thank you!
So I found this posting a few days ago. I used the code pen and am trying to make this into a dynamically loading setup. Everything is fine with the wedges until you get below 4 slices. At 3 and less it breaks. I feel like it's something to do with the aspect ration of the LI tags.
Any thoughts?
I suppose this would be easier done in pure Javasript using CSS only where It's appropriate (e.g. the animation). Is it really worth the effort doing anything in CSS?
I don't think that'd be easier in javascript. Whenever you have something visual, the right tool for that is CSS. When it's easier in pure JS, this usually mean that you lack knowledge with CSS.
Oh, have fun to rebuild the [solarsystem][dev.to/cookiemonsterdev/solar-syst...] with pure CSS. There are good reasons the S in
CSS comes from "style", not from graphics...