Draw Circle using css alone [duplicate]

2020-01-25 03:59发布

Is it possible to draw circle using css only which can work on most of the browsers (IE,Mozilla,Safari) ?

7条回答
叼着烟拽天下
2楼-- · 2020-01-25 04:37

Yep, draw a box and give it a border radius that is half the width of the box:

#circle {
    background: #f00;
    width: 200px;
    height: 200px;
    border-radius: 50%;
}

Working demo:

http://jsfiddle.net/DsW9h/1/

#circle {
    background: #f00;
    width: 200px;
    height: 200px;
    border-radius: 50%;
}
<div id="circle"></div>

查看更多
成全新的幸福
3楼-- · 2020-01-25 04:37

This will work in all browsers

#circle {
    background: #f00;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    -moz-border-radius: 50%;
    -webkit-border-radius: 50%;
}
查看更多
ゆ 、 Hurt°
4楼-- · 2020-01-25 04:54

You could use a .before with a content with a unicode symbol for a circle (25CF).

.circle:before {
  content: ' \25CF';
  font-size: 200px;
}
<span class="circle"></span>

I suggest this as border-radius won't work in IE8 and below (I recognize the fact that the suggestion is a bit mental).

查看更多
老娘就宠你
5楼-- · 2020-01-25 04:54

yes it is possible you can use border-radius CSS property. For more info have a look at http://zeeshanmkhan.com/post/2/css-rounded-corner-gradient-drop-shadow-and-opacity

查看更多
SAY GOODBYE
6楼-- · 2020-01-25 04:55

yup.. here's my code:

<style>
  .circle{
     width: 100px;
     height: 100px;
     border-radius: 50%;
     background-color: blue
  }
</style>
<div class="circle">
</div>
查看更多
你好瞎i
7楼-- · 2020-01-25 04:59

border radius is good option, if struggling with old IE versions then try HTML codes

&#8226;

and use css to change color. Output:

查看更多
登录 后发表回答