views:

21007

answers:

8

Hi,

I've been looking at various scripts for adding automatic rounded corners to a div using jQuery but there are loads of plugins available, none of which seem perfect.

So, does anybody know of a script that is quick to render, supports IE6, anti-aliases and supports opacity?

Any help would really be appreciated, Jon.

+22  A: 

These should do the trick.

jQuery curvy corners

original curvy corners

geowa4
Note that these links refer to the 2008 version of the script. The new source has been moved to Google code: http://code.google.com/p/jquerycurvycorners/
Pascal Lindelauf
Word of caution: this plugin determines the height of the div to be rounded at load time (at least version 2.1 does) and then fixates that height. I found two problems with this: (1) in a Webkit browser, the height determination sometimes seems to happen too early, thereby getting too small a div; (2) when you vary the div's content with Javascript in such a way that the div's height should be increased (e.g. you load the div's content with an Ajax call), the height is not adjusted as you expect it to be.
Pascal Lindelauf
+1  A: 

The best I have used is one called "rounded corners"

Website is at: http://www.atblabs.com/jquery.corners.html

jQuery plugin link: http://plugins.jquery.com/project/corners

Jon
The www.atblabs.com link is now dead. (this is for information, rather than criticism) =)
David Thomas
jquery curvy corners looks great, thanks :)
Tisch
A: 

Here's the one I use.

http://jqueryjs.googlecode.com/svn/trunk/plugins/corner/jquery.corner.js

It can be as simple as saying

$("#divname").corner();

It defnitely scores on working with IE6 and anti-aliasing, but I can't speak for opacity.

Julian
+9  A: 

Lately I've been using the new CSS3 rounded corners for Firefox, Chrome, Opera & Safari and just leaving IE with normal square corners. It's just not worth the time to do it for IE.

Update:

IE9 will have rounded corners.

Donny V.
10.50 has added rounded corners
presario
Sorry I meant Opera 10.50 has added rounded corners.
presario
+2  A: 

jQuery corners has a new beta version @ jQuery corners

troy_k
+2  A: 

jQuery Background Canvas supports IE6, anti-aliases and supports opacity. But it isn't that nifty insert some corners stuff. It gives you full control about the background rendering.

Look at tis sample:

$(document).ready(function()
{
$(".Test").backgroundCanvas();
});

function DrawBackground() {
$(".Test").backgroundCanvasPaint(TestBackgroundPaintFkt);
}
// Draw the background on load and resize
$(window).load(function () { DrawBackground(); });
$(window).resize(function() { DrawBackground(); });

function TestBackgroundPaintFkt(context, width, height, elementInfo)
{
var options = {x:0, height: height, width: width,
radius:14, border: 0 };
// Draw the red border rectangle
context.fillStyle = "#FF0000";
$.canvasPaint.roundedRect(context,options);
// Draw the gradient filled inner rectangle
var backgroundGradient = context.createLinearGradient(0, 0,
0, height - 10);
backgroundGradient.addColorStop(0 ,'#AAAAFF');
backgroundGradient.addColorStop(1, '#AAFFAA');
options.border = 5;
context.fillStyle = backgroundGradient;
$.canvasPaint.roundedRect(context,options);
}

Here is the plugin, and this site makes a vast use of it: jQuery Background Canvas Plugin

Thomas Maierhofer
Thomas, I'd love to use this, but it needs to be much easier to use. You can get rounded corners with 1 line of code using malsup's plugin. I understand that it uses a bunch of extra HTML elements and yours doesn't, but I don't want to have 20-something lines of code just to get rounded corners on something.
Daniel Schaffer
+3  A: 

I've had lots of success with this jQuery plugin: http://malsup.com/jquery/corner/

There are some parameters to fine tune the appearance. I particularly like the effect of rounding just 2 opposite corners with $('#divName').corner("tl br");.

Fly_Trap
The main problem with that specific approach is, that the background of the corners are colored, not transparent. IMO, that destroys the fitness.
Sune Rasmussen
I usually use this script, although its a bit heavier that needed
WalterJ89
+4  A: 

Not jQuery, but if you're interested in creating rounded corners in IE then this may be of use - http://css3pie.com/

Sniffer
+1 for CSS3Pie -- by **far** the best solution. Stomps all over the JQuery plug ins and other alternatives.
Spudley
+2 excellent tip!
FFish