Tat*_*nen 193
是的,画一个盒子并给它一个边框半径,该半径是盒子宽度的一半:
#circle {
background: #f00;
width: 200px;
height: 200px;
border-radius: 50%;
}
Run Code Online (Sandbox Code Playgroud)
工作演示:
#circle {
background: #f00;
width: 200px;
height: 200px;
border-radius: 50%;
}Run Code Online (Sandbox Code Playgroud)
<div id="circle"></div>Run Code Online (Sandbox Code Playgroud)
Tom*_*Tom 145
你可以使用带有unicode符号的内容的.before(25CF).
.circle:before {
content: ' \25CF';
font-size: 200px;
}Run Code Online (Sandbox Code Playgroud)
<span class="circle"></span>Run Code Online (Sandbox Code Playgroud)
我建议这样做,因为border-radius在IE8及以下版本中不起作用(我认识到这个建议有点精神).
jbu*_*483 40
border-radius的50% ,这将使它的形状为圆形.(注意:长时间不需要前缀)background-color/ gradients /(偶数pseudo elements)来创建这样的东西:.red {
background-color: red;
}
.green {
background-color: green;
}
.blue {
background-color: blue;
}
.yellow {
background-color: yellow;
}
.sphere {
height: 200px;
width: 200px;
border-radius: 50%;
text-align: center;
vertical-align: middle;
font-size: 500%;
position: relative;
box-shadow: inset -10px -10px 100px #000, 10px 10px 20px black, inset 0px 0px 10px black;
display: inline-block;
margin: 5%;
}
.sphere::after {
background-color: rgba(255, 255, 255, 0.3);
content: '';
height: 45%;
width: 12%;
position: absolute;
top: 4%;
left: 15%;
border-radius: 50%;
transform: rotate(40deg);
}Run Code Online (Sandbox Code Playgroud)
<div class="sphere red"></div>
<div class="sphere green"></div>
<div class="sphere blue"></div>
<div class="sphere yellow"></div>
<div class="sphere"></div>Run Code Online (Sandbox Code Playgroud)
Sun*_*nit 12
border radius是不错的选择,如果与旧的IE版本挣扎,那么尝试HTML代码
•
Run Code Online (Sandbox Code Playgroud)
并使用CSS来改变颜色.输出:
•
AeJ*_*Jey 10
这适用于所有浏览器
#circle {
background: #f00;
width: 200px;
height: 200px;
border-radius: 50%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
}
Run Code Online (Sandbox Code Playgroud)
小智 9
是..这是我的代码:
<style>
.circle{
width: 100px;
height: 100px;
border-radius: 50%;
background-color: blue
}
</style>
<div class="circle">
</div>
Run Code Online (Sandbox Code Playgroud)
是的,你可以使用border-radius CSS属性.欲了解更多信息,请访问http://zeeshanmkhan.com/post/2/css-rounded-corner-gradient-drop-shadow-and-opacity