css实现图片圆角边效果

因为朋友的关系,最近上facebook比较频繁。
发现上面的圆角图片并不是程序生成的(太费资源),仅仅用“定位”就解决了所有图片的圆角边效果。

该代码运用了 CSS Sprites 图片整合技术 将所有的圆角边框汇聚到一张PNG图片上(PNG兼容),然后外框加“相对定位 position:relative;”和“超出部分隐藏 overflow:hidden;”,在框内,应用绝对定位调整圆角的位置。附言:即日起,将不考虑IE6浏览效果

演示效果:
http://uicss.cn/wp-content/uploads/roundedimage-corners.html

CSS代码:

  1. #roundedimage{
  2. overflow:hidden; width:50px; height:50px;
  3. position:relative;
  4. }
  5. .UIRoundedImage_Corners {
  6. background:transparent none repeat scroll 0 0;
  7. display:block;height:100%;width:100%;
  8. overflow:hidden;
  9. position:absolute;top:0;left:0;
  10. }

html代码:

  1. <div id="roundedimage">
  2. <img alt="Kai Cui" src="http://profile.ak.facebook.com/profile6/1918/57/q1070114775_5686.jpg"/>
  3. <span class="UIRoundedImage_Corners">
  4. <img src="http://static.ak.fbcdn.net/images/ui/UIRoundedImage.png"/>
  5. </span>
  6. </div>

5 条评论 《css实现图片圆角边效果》

  1. :wink:

    回复

  2. :-| 这样都行。。。。 没什么实用性。 只是省去了处理圆角图片这一部

    回复

  3. 高度不固定的时候岂不是有N多这样的图片 :?:

    回复

  4. Gravatarpopoin.com

    在 IE6.0 下面无法实现,能给出解决方法吗?

    回复

  5. facebook负载那么大的的图片资源,省去四个小脚,节约的不是你想象的那么小点资源。强!顶起!

    回复

发表评论 (无需注册)

支持CTRL+ENTER快捷提交
崔凯博客
Powered by WordPress | Theme by ck web design | TOP 顶部
Copyright © 崔凯博客 All rights reserved. 京ICP备09029324号.