用CSS3或图像圆角?

时间:2010-12-27 12:49:32

标签: html css css3 rounded-corners

现在创建它们的不同之处和最佳方式是什么?

4 个答案:

答案 0 :(得分:5)

CSS3,绝对是。它更快更干净,并且在所有主流浏览器上都受支持。 IE需要(惊讶,惊讶)workaround though

-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
behavior: url(border-radius.htc);

答案 1 :(得分:2)

简单来说:

使用图片创建的圆角应适用于所有浏览器。

使用CSS3创建的那些在现代浏览器中工作但不在IE< 9。

  

有什么不同和最好的   现在创建它们的方法?

对于现代浏览器,您应该使用CSS3的borer-radius属性以及特定于供应商的前缀。要在IE中使用圆角,您可以使用:

  

PIE使Internet Explorer 6-8   能够呈现几个   最有用的CSS3装饰功能。

以下是跨浏览器圆角的示例:

#myAwesomeElement {
    border: 1px solid #999;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    behavior: url(path/to/PIE.htc);
}

答案 2 :(得分:1)

您可以使用jQuery插件CurvyCorners

如果您不想使用css3

答案 3 :(得分:0)

jQuery插件lc_roundz http://coffeelog.itsatony.com/?p=86将动态完成工作 - 即使您希望角落是透明的(例如,用于复杂背景,......)。

$("#image").lc_roundz({  
radius: 20,  // corner-radius  
newDadSelector: "", // jQuery style selector string to allow attachment anywhere in the DOM. empty string will inject the canvas next to the original  
newid: "%oid_after_lc_roundz",      // the new ID for the canvas object. %oid will be replaced with the id of the original object  
width: -1,                                                           // -1 uses the original image's width  
height: -1,                    // -1 uses the original image's width  
replace: false,                                          // boolean to decide whether the original should be removed from the DOM  
corner_color: [0,0,0,0]                     // this means TRANSPARENT ... R,G,B,alpha [0-255] each  
});