简体   繁体   English

CSS 跨浏览器弯曲边框

[英]CSS Cross-Browser Curved Borders

What is the correct/best way to define cross-browser CSS/CSS3 compliant/valid curved borders?定义跨浏览器 CSS/CSS3 兼容/有效弯曲边框的正确/最佳方法是什么?

Is there a non-JavaScript way of doing so, while being cross-browser compatible?在跨浏览器兼容的同时,是否有非 JavaScript 的方式这样做? If not, is there any proper workaround?如果没有,是否有任何适当的解决方法?

Have you tried:你有没有尝试过:

-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px

together?一起? That should cover the primary 3 browsers in their latest releases (at least).这应该涵盖最新版本中的主要 3 个浏览器(至少)。 Without javascript or using images, you're not going to get full cross-browser coverage.没有 javascript 或使用图像,您将无法获得完整的跨浏览器覆盖。

See the CSS Border Radius Generator (simple rounded corners) or CSS3 Please (more effects) for a CSS-only solution.请参阅CSS Border Radius Generator (简单圆角)或CSS3 Please (更多效果)以获取纯 CSS 解决方案。 If you want something that works in Firefox 3.0+, Safari 3.0+, Chrome 5.0+, Opera 9.5+ and Internet Explorer 6.0+ with no images then try Raphaël .如果您想要在 Firefox 3.0+、Safari 3.0+、Chrome 5.0+、Opera 9.5+ 和 Internet Explorer 6.0+ 中运行而没有图像的东西,请尝试Raphaël Here's a nice talk by Dmitry Baranovskiy , author of Raphaël, explaining why it's cool.这是 Raphaël 的作者Dmitry Baranovskiy精彩演讲,解释了为什么它很酷。

The best way to do it is with border-radius.最好的方法是使用边界半径。

-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px

This is only compatible in Safari, Firefox and Chrome.这仅在 Safari、Firefox 和 Chrome 中兼容。 This does not work for IE 7+8 (and less)这不适用于 IE 7+8(及更少)

If you want the most compatibility but the least amount of flexibility, images are the way to go.如果您想要最大的兼容性但最小的灵活性,图像是要走的路。

If you want flexibility and browser compatibility go with javascript.如果您想要灵活性和浏览器兼容性,请使用 javascript。 The best one I have found converts the CSS3 declatation to rounder corners in IE 7+8.我发现的最好的一个将 CSS3 declatation 转换为 IE 7+8 中的圆角。

Check that one out here: http://www.curvycorners.net/在这里检查一个: http : //www.curvycorners.net/

You should use this:你应该使用这个:

-moz-border-radius: 20px;
border-radius: 20px

WebKit has supported plain border-radius for a while now. WebKit 支持纯border-radius已经有一段时间了。

http://css3generator.com/ for example, has dropped the -webkit prefix.例如, http: -webkit删除了-webkit前缀。

To make this work in Internet Explorer, I recommend using CSS3 PIE , which is as simple as downloading a small file, and adding this to your CSS:为了在 Internet Explorer 中完成这项工作,我建议使用CSS3 PIE ,这就像下载一个小文件并将其添加到您的 CSS 中一样简单:

behavior: url(PIE.htc)

Of course, this will only work when Javascript is turned on in IE (which is usually the case).当然,这只有在 IE 中打开 Javascript 时才有效(通常是这种情况)。

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

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