繁体   English   中英

使用CSS3或带图像的圆角?

[英]Rounder corners with CSS3 or with images?

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

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

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

简单来说:

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

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

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

你应该使用CSS3的borer-radius propery以及现代浏览器的特定于供应商的前缀。 要在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);
}

您可以使用jQuery插件CurvyCorners

如果你不想使用css3

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  
}); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM