简体   繁体   English

如何使用CSS的圆形边框?

[英]How can I use rounded borders with CSS?

Is there a way in the newer CSS standards to provide round borders? 新的CSS标准中是否有办法提供圆形边框? It is not possible in CSS level 2. 在CSS级别2中是不可能的。

Yes. 是。 CSS3 already has it. CSS3已经拥有它。

Many browsers already have it. 许多浏览器已经拥有它。

  • In Mozilla/gecko browsers you need -moz-border-radius though they are transitioning to border-radius . 在Mozilla / gecko浏览器中,你需要-moz-border-radius尽管它们正在转换到border-radius
  • In Safari/Chrome/webkit browsers you need -webkit-border-radius . 在Safari / Chrome / webkit浏览器中,您需要-webkit-border-radius
  • IE9 and above need border-radius (IE8 and below don't support it at all). IE9及以上版本需要border-radius (IE8及以下版本根本不支持)。
  • In the future when CSS3 is widely adopted you'll just need border-radius in all browsers. 在CSS3被广泛采用的未来,你只需要在所有浏览器中使用border-radius

At the moment it's a good idea to use all three, plus -o-border-radius if you're worried about Opera. 目前,如果您担心Opera,最好使用全部三个加上-o-border-radius

Border-radius: create rounded corners with CSS! Border-radius:用CSS创建圆角!

This box should have a rounded corners for Firefox, Safari/Chrome, Opera and IE9. 这个盒子应该有一个圆角适用于Firefox,Safari / Chrome,Opera和IE9。 The code for this example is, in theory, quite simple: 从理论上讲,这个例子的代码非常简单:

#example1 {
border-radius: 15px;
}

However, for the moment, you'll also need to use the -moz- prefix to support Firefox (see the browser support section of this article for further details): 但是,目前,您还需要使用-moz-前缀来支持Firefox(有关详细信息,请参阅本文的浏览器支持部分):

#example1 {
-moz-border-radius: 15px;
border-radius: 15px;
}

Thomas Rutter所说的 ,加上这里是一个方便的资源,因为WebKit和Gecko对top-left等事物使用不同的属性。

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

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