简体   繁体   English

如何在Google Chrome中使用CSS进行圆角处理

[英]How do I do rounded corners in CSS in Google Chrome

基本上我想弄清楚我如何在CSS中使用谷歌浏览器渲染的DIV圆角

Google Chrome (and Safari) work with the following CSS 3 prefixes Google Chrome(和Safari)使用以下CSS 3前缀

-webkit-border-radius: 10px;

for all corners at 10px 适用于10px的所有角落

-webkit-border-top-left-radius: 8px;
-webkit-border-bottom-left-radius: 8px;

for the top left corner and bottom left at 8px 左上角和左下角为8px

For Firefox you can use: 对于Firefox,您可以使用:

-moz-border-radius: 10px;

for all the corners and 所有的角落和

-moz-border-radius-topleft: 8px;
-moz-border-radius-bottomleft: 8px;

for the top left corner and bottom left 左上角和左下角

要涵盖Chrome,FF和支持CSS 3的任何浏览器:

{-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;}

It's future-useful to code your css like this: 这样编写你的css是非常有用的:

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

That way, when IE9/IE10 comes out your code will also work there as well :D 这样,当IE9 / IE10出来时,你的代码也会在那里工作:D

Given that all browsers now support border-radius without prefixes; 鉴于所有浏览器现在都支持没有前缀的border-radius; see: http://caniuse.com/#search=border-radius the correct syntax to use today is simply: 请参阅: http//caniuse.com/#search=border-radius今天使用的正确语法很简单:

border-radius: 5px;

Yes but the only problem with this is that you are actually throwing css errors because of IE being jacked and Microshaft not wanting to do anything about it, the fix that i use is js based but I imagine most people know all about that. 是的,但唯一的问题是,你实际上是因为IE被顶起而且微管不想对它做任何事情而引发css错误,我使用的修复是基于js但我想大多数人都知道这一切。 But, the reason I use it is because it always works for me and on all the major browsers. 但是,我使用它的原因是因为它总是适用于我和所有主流浏览器。 Here you go. 干得好。

var obj= document.getElementById('divName');
var browserName=navigator.appName; 
var browserVer=parseInt(navigator.appVersion); 
//alert(browserName);
if ((browserName=="Microsoft Internet Explorer")) {
obj.style.borderRadius = "15px";
}else {
    obj.style.MozBorderRadius = "15px";
    obj.style.WebkitBorderRadius= "15px";

}

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

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