DIV+CSS圆角效果轻松实现

开发 前端
做网站设计的时候,免不了和DIV+CSS打交道,而DIV+CSS圆角则是网站设计必经的一课,比较了网络上众多的DIV+CSS圆角实现的方案都不容乐观,这里向大家描述一种简洁实用的方法,

本节向大家介绍一下DIV+CSS圆角的简单实现方法,即使用图片做背景的DIV+CSS圆角实现方案。一张图片利用CSS定位,实现DIV的四个边角都是圆角。这样的好处是,只需要一张圆形的图片,就可以实现四个圆角了。

DIV+CSS圆角的简单实现方法

做网站设计的时候,免不了和DIV+CSS打交道,而DIV+CSS圆角则是网站设计必经的一课。比较了网络上众多的DIV+CSS圆角实现的方案,包括不用图片纯CSS实现圆角的许多方案,结果是不用图片的DIV+CSS圆角无一例外,都使用了大量的冗余无意义的css代码,而且在IE、Firefox、chrome等多浏览器下的兼容性不容乐观。

总结一下,建议大家还是使用图片做背景的DIV+CSS圆角实现方案。一张图片利用CSS定位,实现DIV的四个边角都是圆角。这样的好处是,只需要一张圆形的图片,就可以实现四个圆角了。

HTML代码: 

  1. <divclassdivclass="nav"> 
  2. <divclassdivclass="nav2"> 
  3. <SPANclassSPANclass=leftTop></SPAN> 
  4. <SPANclassSPANclass=rightTop></SPAN> 
  5.  

这里是主体内容....

  1. <SPANclassSPANclass=leftBottom></SPAN> 
  2. <SPANclassSPANclass=rightBottom></SPAN> 
  3. </div> 
  4. </div> 

CSS代码: 

  1. .nav{  
  2. position:relative;  
  3. width:500px;  
  4. margin:0pxauto;  
  5. background:#eeeeee;  
  6. }  
  7. .nav2{  
  8. border:1pxsolid#dddddd;  
  9. padding:4px0px2px0px;  
  10. height:42px;  
  11. text-align:center;  
  12. }  
  13.  
  14. /*DIV+CSS圆角处理*/  
  15. .nav.leftTop{/*DIV+CSS圆角左上角*/  
  16. background:url(images/wbb.gif)no-repeatlefttop;  
  17. width:10px;  
  18. height:10px;  
  19. position:absolute;  
  20. left:0;  
  21. top:0;  
  22. }  
  23. .nav.rightTop{/*DIV+CSS圆角右上角*/  
  24. background:url(images/wbb.gif)no-repeatrighttop;  
  25. width:10px;  
  26. height:10px;  
  27. position:absolute;  
  28. right:0;  
  29. top:0;  
  30. }  
  31. .nav.leftBottom{/*DIV+CSS圆角左下角*/  
  32. background:url(images/wbb.gif)no-repeatleftbottom;  
  33. width:10px;  
  34. height:10px;  
  35. position:absolute;  
  36. left:0;  
  37. bottom:0;  
  38. }  
  39. .nav.rightBottom{/*DIV+CSS圆角右下角*/  
  40. background:url(images/wbb.gif)no-repeatrightbottom;  
  41. width:10px;  
  42. height:10px;  
  43. position:absolute;  
  44. right:0;  
  45. bottom:0;  
  46. }  
  47. /*DIV+CSS圆角处理end*/  

【编辑推荐】

  1. DIV CSS网页布局时合理架构CSS
  2. 技术分享 如何实现CSS横向导航
  3. 技术分享 DIV CSS网站布局八大窍门
  4. DIV CSS中id与class使用用原则与技巧
  5. 鼠标经过时改变DIV背景颜色的三种途径

 

责任编辑:佚名 来源: piaoyi.org
相关推荐

2010-08-26 15:59:38

DIV圆角

2010-08-25 09:11:57

DIVCSS

2010-08-24 10:32:34

DIV+CSS

2010-08-27 14:05:40

DIV+CSS

2010-08-30 10:46:13

DIV+CSS

2010-09-14 11:19:23

DIV+CSS技术

2010-08-30 13:09:40

DIVCSS

2010-08-25 12:47:40

DIVCSS

2010-08-16 15:19:35

DIV+CSS教程

2012-08-06 09:40:36

DIV

2010-08-24 11:25:06

DIVCSS

2011-05-17 09:51:27

Div+CSS

2010-09-07 09:30:25

DIV弹出jQuery

2010-09-09 10:07:05

DIVCSS

2010-08-16 13:17:47

DIV+CSS

2010-08-30 11:08:53

DIV+CSS

2010-08-23 14:30:14

DIV+CSS

2011-05-26 18:05:01

DIV+CSS

2011-07-05 16:26:48

DIV+CSS

2010-08-16 16:17:21

点赞
收藏

51CTO技术栈公众号