Fe-interview: [css] 第180天 请使用css画一个圆,方法可以多种

Created on 12 Oct 2019  ·  2Comments  ·  Source: haizlin/fe-interview

第180天 请使用css画一个圆,方法可以多种

css

Most helpful comment

<div class="circle"></div>

1.border-radius

.cirlce{
 width:10vw; height:10vw; background:gray;
 border-radius:50%;
}

2.clip-path

.circle{
 width:10vw; height:10vw; background:gray;
 clip-path: circle();
}

3.svg background

.circle{
width:10vw; height:10vw; 
 background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='50%25' cy='50%25' r='50%25' fill='gray'/%3E%3C/svg%3E");
}

4.radial-gradient

.circle{
 width:10vw; height:10vw; 
 background:radial-gradient(gray 70%, transparent 70%);
}

5.font

.circle::after {
    content: "●";
    font-size: 10vw;//字体实际大小
    line-height: 1;
}

6.mix-blend-mode

.circle{
 width: 10vw;height: 10vw;background: gray;
}
.circle::after {
    content: "";display: block;width: 10vw;height: 10vw;
    mix-blend-mode: lighten;
    background: radial-gradient(#000 70%, #fff 70%);
}

All 2 comments

<div class="circle"></div>

1.border-radius

.cirlce{
 width:10vw; height:10vw; background:gray;
 border-radius:50%;
}

2.clip-path

.circle{
 width:10vw; height:10vw; background:gray;
 clip-path: circle();
}

3.svg background

.circle{
width:10vw; height:10vw; 
 background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='50%25' cy='50%25' r='50%25' fill='gray'/%3E%3C/svg%3E");
}

4.radial-gradient

.circle{
 width:10vw; height:10vw; 
 background:radial-gradient(gray 70%, transparent 70%);
}

5.font

.circle::after {
    content: "●";
    font-size: 10vw;//字体实际大小
    line-height: 1;
}

6.mix-blend-mode

.circle{
 width: 10vw;height: 10vw;background: gray;
}
.circle::after {
    content: "";display: block;width: 10vw;height: 10vw;
    mix-blend-mode: lighten;
    background: radial-gradient(#000 70%, #fff 70%);
}

最常见的就是用border-radius了,其他的 还是看上面那位的吧

Was this page helpful?
0 / 5 - 0 ratings