使用边框半径绘制圆圈

Dan*_*hez 3 css jquery css3

我正在尝试使用边框半径转换一些div.我几乎得到它,但有时div看起来像'鸡蛋'哈哈这是我的CSS:

#div{   /*div central*/
    position:absolute;
    top:50%;
    margin-top: -20%;
    left:50%;
    margin-left: -20%;
    background: #00A8D9;
    width: 40%;
    height: 40%;
    -moz-border-radius: 50%;
    -webkit-border-radius: 50%;
    border-radius: 50%;
    border:3px solid #000;
}
#divSupIzq,#divSupDer,#divInfIzq,#divInfDer{    /*DIVs: left-top , right-top, left-bottom, right-bottom*/
    background: #ddd;
    width: 20%;
    height: 20%;
    -moz-border-radius: 50%;
    -webkit-border-radius: 50%;
    border-radius: 50%;
    border:3px solid #fff;
    position:absolute;
}
#divSupIzq{  /*Div left-top*/
    top:15%;
    left:10%;
}
#divSupDer{ /*Div right-top*/
    top:15%;
    right:10%;
}
#divInfIzq{ /*Div left-bottom*/
    bottom:15%;
    left:10%;
}
#divInfDer{ /*Div right-bottom*/
    bottom:15%;
    right:10%;
}
Run Code Online (Sandbox Code Playgroud)

在html中,我使用javascript/jQuery来改变每个div的内容(基本上是div中的文本:左上角,右上角,左下角,右下角;以及中央div中的数字)取决于每个div的大小:

$('#div').resize(function(height){
                    var fuente = $(this).height()/2;
                    var margen = (fuente / 2)-5;
                    $('.contenido').css('font-size',fuente+'px');
                    $('.contenido').css('margin-top',margen+'px');  
                });
Run Code Online (Sandbox Code Playgroud)

这就是我在Chrome的Ripple扩展中看到的:https: //www.dropbox.com/s/k71kz5lahfolw95/screen.JPG

你可以帮助我,以便div总是圈,而不是鸡蛋? 谢谢,丹尼尔

abh*_*kdz 9

绘制圆圈:

HTML

<div id="circle"></div>
Run Code Online (Sandbox Code Playgroud)

CSS

#circle {
    width: 100px;
    height: 100px;
    background: red;
    -moz-border-radius: 50px;
    -webkit-border-radius: 50px;
    border-radius: 50px;
}
Run Code Online (Sandbox Code Playgroud)

是上面的小提琴.

固定宽度和高度:http://jsfiddle.net/eC3jq/1/

circle包含在一个div%宽度和高度正常工作:http://jsfiddle.net/eC3jq/2/

资料来源:CSS-Tricks