What I\'m trying to do is create a simple donut chart. I\'m currently using CSS(3) only but I don\'t know if it\'s possible without javascript.
What I have so far:
I have modified a snippet I found on the web to make a simple doughnut chart using only HTML and CSS, here is the result:
.block {
margin: 25px 25px 0 0;
background: #394264;
border-radius: 5px;
float: left;
width: 300px;
overflow: hidden;
}
.donut-chart-block {
overflow: hidden;
}
.donut-chart {
position: relative;
width: 200px;
height: 200px;
margin: 2rem auto;
border-radius: 100%
}
.donut-chart .center {
background: #394264;
position: absolute;
top: 30px;
left: 30px;
height: 140px;
width: 140px;
border-radius: 70px;
}
.clip {
border-radius: 50%;
clip: rect(0px, 200px, 200px, 100px);
height: 100%;
position: absolute;
width: 100%;
}
.item {
border-radius: 50%;
clip: rect(0px, 100px, 200px, 0px);
height: 100%;
position: absolute;
width: 100%;
font-family: monospace;
font-size: 1.5rem;
}
#section1 {
transform: rotate(0deg);
}
#section1 .item {
background-color: #E64C65;
transform: rotate(76deg);
}
#section2 {
transform: rotate(76deg);
}
#section2 .item {
background-color: #11A8AB;
transform: rotate(140deg);
}
#section3 {
transform: rotate(215deg);
}
#section3 .item {
background-color: #4FC4F6;
transform: rotate(113deg);
}
#section4 {
transform: rotate(-32deg);
}
#section4 .item {
background-color: #FCB150;
transform: rotate(32deg);
}
Decided to post it here as an alternative to the other answers. Cheers!