How to create a donut with rounded edges in one direction and a white border between segments

0 votes

How to create a donut with rounded edges in one direction and a white border between segments?

I am trying to create a donut chart with a specific styling where each segment has rounded edges on one side to give it a smooth, polished appearance. Additionally, I want to include a white border or gap between the segments to clearly distinguish them, but I am struggling to implement both features simultaneously. While I can create a basic donut chart, adding these stylistic elements has proven challenging. How can I achieve this design effectively

Dec 4, 2024 in Web Development by Nidhi
• 5,060 points
68 views

1 answer to this question.

0 votes

You can use CSS and conic-gradient for creating donut charts.

Approach:

Create the donut shape using a circular div.

Use conic-gradient to create colored segments in the donut with a white border.

Apply border-radius to give the segments a rounded edge in one direction.

Steps:

HTML:

<div class="donut"></div>

CSS:

.donut {

  width: 400px;

  height: 400px;

  border-radius: 50%; /* Make it circular */

  background: conic-gradient(

    #ff0000 0% 25%,     /* Red segment (25%) */

    #00ff00 25% 50%,    /* Green segment (25%) */

    #0000ff 50% 75%,    /* Blue segment (25%) */

    #ff00ff 75% 100%    /* Purple segment (25%) */

  );

  border: 20px solid white; /* White border between segments */

  background-clip: content-box; /* Ensure the border doesn't overlap the donut */

}

answered Dec 4, 2024 by navya

Related Questions In Web Development

0 votes
0 answers

How to generate a service and include the provider in one step with Angular CLI?

How to generate a service and include ...READ MORE

Dec 13, 2024 in Web Development by Nidhi
• 5,060 points
30 views
0 votes
0 answers
0 votes
1 answer

How to create a node in a linked list?

A linked list is a linear data structure ...READ MORE

answered Nov 6, 2024 in Web Development by kavya
179 views
0 votes
1 answer

How to create a horizontal line in CSS?

The most basic way to create a ...READ MORE

answered Nov 4, 2024 in Web Development by kavya
94 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
10,676 views
0 votes
1 answer

Using/Handling colon inside a JSF generated HTML element ID in CSS selector

Yes, you can.  Just Backslash (\) the colon.  Like ...READ MORE

answered Nov 14, 2018 in Others by DataKing99
• 8,250 points
2,906 views
0 votes
1 answer

What is a css selector and where is it used?

CSS Selector is a combination of element ...READ MORE

answered Nov 21, 2018 in Data Analytics by Kalgi
• 52,350 points
984 views
0 votes
1 answer

How to Align a Home Button and Dropdown Menus on the Same Line in a Navigation Bar?

Using CSS Flexbox, you can center a ...READ MORE

answered Dec 12, 2024 in Web Development by Navya
45 views
0 votes
1 answer

How do I send a file from postman to node.js with multer?

npm install multer express Then  we will set ...READ MORE

answered Oct 24, 2024 in Web Development by kavya

edited Oct 30, 2024 by Nidhi 225 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP