简体   繁体   English

圆角

[英]Rounded Corners

I am wondering whats the best way to programmatically make rounded corners for images. 我想知道以编程方式为图像制作圆角的最佳方法是什么。 This can be either using PHP or javascript. 可以使用PHP或javascript。 An algorithm will also do for the same and I can code it with Image::Magick or GD. 一个算法也可以做到这一点,我可以用Image :: Magick或GD对其进行编码。

Thank you for your time. 感谢您的时间。

Use border-radius . 使用border-radius

It is supported in IE9+, Firefox 4+, Chrome, Safari 5+, and Opera. IE9 +,Firefox 4 +,Chrome,Safari 5+和Opera支持该功能。

For the best possible browser support, you should prefix with -webkit- and -moz- : 为了获得最好的浏览器支持,您应该在-webkit--moz-前缀:

.round {
  /* Safari 3-4, iOS 1-3.2, Android 1.6- */
  -webkit-border-radius: 12px; 

  /* Firefox 1-3.6 */
  -moz-border-radius: 12px; 

  /* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
  border-radius: 12px; 
}

If you need a JavaScript solution for older browsers check out jQuery Corner . 如果您需要旧版浏览器的JavaScript解决方案,请查看jQuery Corner

Well, it depends what exactly you need. 好吧,这取决于您到底需要什么。 Do you want the corners to be transparent, or filled in some color? 您是否希望角落是透明的或以某种颜色填充的? Which image format? 哪种图像格式?

Here is some help for making rounded corners: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=8401 这里有一些帮助圆角的方法: http : //www.imagemagick.org/discourse-server/viewtopic.php? f=1&t= 8401

Check it out, and if it does not help, update your question with the specific problem. 进行检查,如果没有帮助,请使用特定问题更新您的问题。 Then we can probably help :-): 那么我们可能可以帮助:-):

use JavaScript to programatically get round corners 使用JavaScript以编程方式获得圆角

OR 要么

you can use mozilla and safaris browser extensions to get round corners using CSS but it will work only in Mozilla and Safari 您可以使用mozilla和safaris浏览器扩展程序来使用CSS取得成功,但仅在Mozilla和Safari中有效

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

You can use the above mention tags with CSS, and for IE, use DDRoundies with some jquery code to make it work in IE. 您可以在CSS中使用上述标记,对于IE,请使用带有一些jquery代码的DDRoundies使其在IE中工作。 It is what I had to do to get it working. 这是我必须做的才能使其工作。 Good example of this is http://swiftmailer.org/ site. http://swiftmailer.org/网站就是一个很好的例子。 they make use of what I mentioned. 他们利用了我提到的内容。

Here are links for two PHP based solutions: 这是两个基于PHP的解决方案的链接:

  1. Apply rounded corners to images is a PHP script that embeds rounded corner on the image itself 将圆角应用于图像是一个PHP脚本,它在图像本身上嵌入了圆角
  2. PHP rounded corner generator script generates four corners that you can place over your image using CSS positioning -- or you can use them in your CSS/HTML layouts that require boxes with round corner. PHP圆角生成器脚本会生成四个角,您可以使用CSS定位将其放置在图像上-或者可以在需要带圆角框的CSS / HTML布局中使用它们。

另一个是Thumbnailer类。

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

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