I know you can make a circle in CSS3 using the border radius hack. But is there any way to make them have segments like this picture? Is there a way of doing this through HT
You can use a conic gradient
Conic gradients basically go around the shape, like a circle, from 0° to 360°.
Here is a basic conic gradient, with a circle:
div {
width: 500px;
height: 500px;
border-radius: 9999px;
background: red; /* fallback */
background: conic-gradient(red, orange, yellow, green, blue, purple);
}
Using color stops, we can then, magically, turn it into segments:
div {
width: 500px;
height: 500px;
border-radius: 9999px;
background: red; /* fallback */
background: conic-gradient(red 10%, orange 10%, orange 30%, yellow 30%, yellow 50%, green 50%, green 60%, blue 60%, blue 70%, purple 70%);
}
Optionally, if we only want one slice, we can now change this so we only have one colour, and now we're good to go :)
div {
width: 500px;
height: 500px;
border-radius: 9999px;
background: red; /* fallback */
background: conic-gradient(#0000 40%, red 40%, red 70%, #0000 70%);
}