Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css] 第222天 用css实现饼图效果 #1558

Open
haizhilin2013 opened this issue Nov 23, 2019 · 2 comments
Open

[css] 第222天 用css实现饼图效果 #1558

haizhilin2013 opened this issue Nov 23, 2019 · 2 comments
Labels
css css

Comments

@haizhilin2013
Copy link
Collaborator

第222天 用css实现饼图效果

我也要出题

@haizhilin2013 haizhilin2013 added the css css label Nov 23, 2019
@everast2015
Copy link

方法一、使用伪元素 + transform + css渐变实现

    .pie {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background: yellowgreen;
            background-image: linear-gradient(to right, transparent 50%, #655 0);
        }
        
        .pie::before {
            content: '';
            display: block;
            margin-left: 50%;
            height: 100%;
            border-radius: 0 100% 100% 0 / 50%;
            background-color: inherit;
            transform-origin: left;
            transform: rotate(.3turn);
        }

方法二、svg解决方案

 <svg width="100" height="100">
        <circle r="25" cx="50" cy="50"/>
 </svg>
   circle {
            fill: yellowgreen;
            stroke: #655;
            stroke-width: 50;
            stroke-dasharray: 60 158;
       }
        
        svg {
            transform: rotate(-90deg);
            background: yellowgreen;
            border-radius: 50%;
       }

@cxyxiaoyuyu
Copy link

使用角向渐变 conic-gradient

.pie{
    width: 200px;
    height:200px;
    border-radius: 50%;
    background: conic-gradient(#2ecc7e 0 30%,#ABCDEF 30% 60%,pink 60% 100%);
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css css
Projects
None yet
Development

No branches or pull requests

3 participants