在 CSS3 之前,做圓角得靠切圖或多層背景拼湊;有了 border-radius,一行聲明即可。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>CSS3 實現 DIV 圓角</title>
<style type="text/css">
#yuanjiao {
font-family: Arial;
border: 2px solid #379082;
border-radius: 20px;
padding: 30px 30px;
width: 330px;
}
</style>
</head>
<body>
<div id="yuanjiao">
本實例演示 CSS3 實現 DIV 圓角,核心代碼只有一句:border-radius: 20px;
</div>
</body>
</html>
border-radius: 10px 20px 30px 40px 分別控制左上、右上、右下、左下。border-top-left-radius、border-top-right-radius、border-bottom-right-radius、border-bottom-left-radius。border-radius: 20px / 40px。效果圖(Chrome):

若項目仍需兼容 IE8 及以下,歷史上曾用 -webkit-border-radius、-moz-border-radius 前綴配合 VML 或背景圖兜底;如今則可放心直接使用標準寫法。