Using pseudo-elements
- First we create our circle, with an
height
and width
and a
border-radius
.
- We add a
background
to our circle and a background-image
with an other
color who will be hided by our pseudo-elements.
- We create our pseudo-elements with a
margin-left
50% so that he can cover the half of
our circle, and we add a background-color inherit so he takes the same color than his parent (yellowgreen).
- We now add a
border-radius
to our pseudo-elements so now he has the exact same shape of his parent.
- We add a
transform-origin
to our pseudo-elements so that he could rotate
around the circle center.
- Finally we add
transform rotate
to turn the circle and show the brown hided color.
More than 50%
- With the old method if try tu show more 50% it won't works.
- To do that we can simply inverted the color of our pseudo-elements.
- Change the
background-color
inherit by background
#655 and it should be works.
- We can add some
animation
;).