使用CSS实现圆角Div(无图片)

来源:互联网 发布:java xmlencoder 编辑:程序博客网 时间:2024/05/16 10:37
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
<style>  
body{ margin:0; padding:20px; font-size:12px; line-height:1.8em; } 
#nifty{ background: #014477;} 
#nifty span{ padding:20px; color:#FFF; display:block;}  
.rtop, .rbottom{ display:block; background:#FFF}  
.rtop div, .rbottom div{ display:block; height:1px; overflow:hidden; background: #014477}  
.r1{margin: 0 7px}  
.r2{margin: 0 5px}  
.r3{margin: 0 3px}  
.r4{margin: 0 2px}  
.rtop .r5, .rbottom .r5{margin: 0 1px;height: 2px}  
</style>  
<title>圆角边框</title>  
</head>  
<body>  
<div id="nifty">  
<div class="rtop"><div class="r1"></div><div class="r2"></div><div class="r3"></div><div class="r4"></div><div class="r5"></div></div>  
<span class="text">第三种方法不用到图片,原理是通过div的嵌套和div设置的margin值的递增来实现圆角 </span>  
<div class="rbottom"><div class="r5"></div><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div>  
</div>  
<p>这个圆角框可以自由伸展,四个方向都能自适应,而且,不用图片</p>  
<p><a href="http://www.zknight.net">返回骑士的博客</a></p>  
</body>  
</html>
0 0
原创粉丝点击