
Untitled
By: a guest on
Aug 12th, 2012 | syntax:
None | size: 1.74 KB | hits: 9 | expires: Never
draw circles using border radius
#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%;
}
$('#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');
});
<div id="circle"></div>
#circle {
width: 100px;
height: 100px;
background: red;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
}
$(window).resize(function(height) {
var div = $('#div');
var width = $('body').width() * 0.4;
var radius = width/2;
width += 'px';
radius += 'px';
div.css({
width: width, height: width,
'-moz-border-radius' : radius,
'-webkit-border-radius' : radius,
'border-radius' : radius
});
// rest of your code for font-size setting etc..
});
$(window).resize();