.div {
width: 100px;
height: 50px;
border-radius: 25px;
}
不好看。。。
我之前给公司做的一个网站有类似的代码,截图是这样子的:
我把它整理了一下,代码如下:
css画椭圆
<div class="container introduce">
<div class="introduce_zi">
<div class="introduce_sun"></div>
</div>
</div><!--introduce-->
/*introduce*/
.introduce{max-width:700px; height:260px; background-color:#62a97b; border-radius:50%; overflow:hidden; position:relative; z-index:2;}
.introduce .introduce_zi{max-width:640px; height:200px; background-color:#26699e; border-radius:50%; margin:0 auto; position:relative; top:-25px;}
.introduce .introduce_zi .introduce_sun{max-width:460px; height:140px; background-color:#593568; border-radius:50%; margin:0 auto; position:relative; top:-25px;}
比较全的,用html5的canvas画的 stackoverflow
<script>
var canvas = document.getElementById('thecanvas');
if(canvas.getContext)
{
var ctx = canvas.getContext('2d');
drawEllipse(ctx, 10, 10, 100, 60);
drawEllipseByCenter(ctx, 60,40,20,10);
}
function drawEllipseByCenter(ctx, cx, cy, w, h) {
drawEllipse(ctx, cx - w/2.0, cy - h/2.0, w, h);
}
function drawEllipse(ctx, x, y, w, h) {
var kappa = .5522848,
ox = (w / 2) * kappa, // control point offset horizontal
oy = (h / 2) * kappa, // control point offset vertical
xe = x + w, // x-end
ye = y + h, // y-end
xm = x + w / 2, // x-middle
ym = y + h / 2; // y-middle
ctx.beginPath();
ctx.moveTo(x, ym);
ctx.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
ctx.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
ctx.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
ctx.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
//ctx.closePath(); // not used correctly, see comments (use to close off open path)
ctx.stroke();
}
</script>
3 回答5.2k 阅读✓ 已解决
5 回答2.1k 阅读
2 回答2k 阅读✓ 已解决
1 回答3.1k 阅读✓ 已解决
3 回答2.5k 阅读
2 回答1.1k 阅读✓ 已解决
2 回答2.2k 阅读
http://css-tricks.com/the-shapes-of-css/