Anti-aliased Rounded corners with JQuery

Rounded CornersRecently I’ve been searching for a method of creating nice looking rounded corners with Javascript & JQuery.

First I found the “JQuery Corner” plugin for rounded corners, but was disappointed that it did not include smooth, anti-aliased corners.

I then did some more google-trawling and found this post, which contained a modified version of Curvy Corners for use with JQuery. Now this script was much much better.

However…the filesize was a massive 40kb, way too big for production use, and to make things worse the code was not compatible with packer so I could not reduce the filesize.

Well, I got busy, and fixed the errors. It is now fully packer friendly meaning easy rounded corners in JQuery at only 9kb 8kb 15kb 20kb 16kb 10kb. Excellent. Read more for the download link.

Demo and download

You can also grab the plugin from Google Code.

Download JQuery Curvy Corners Version 1.9

The packed version is only 10kb, the uncompressed version is 23kb (thats half the size of the original script!).

Quick example

To make a curvy cornered box simply use:

1
		$('.round_this').corner();

Thats all there is too it. A great script!

For more information on Curvy Corners, check out its official site.!

*Edit: Found a small error in IE7 with the backgroundPosition property, fixed now. New file uploaded.

*Edit 2 – 25th Sep 07: More optimizations, smaller file!

*Edit 3 – 29th Sep 07: More optimizations, smaller file, and demo page up!

*Edit 4 – 6th March 08: New version up with better background image support.

*Edit 5 – 19th May 08: No extra padding, safari fixed, larger filesize to reduce overhead and increase speed.

*Edit 6 – 9th Aug 08: General fixes from feedback

*Edit 7 – 7th Oct 08: Major overhaul to improve compatibility with other plugins

*Edit 8 – 2nd June 09: Now compatible with jquery 1.3.2 – All future updates will be on Google Code (http://code.google.com/p/jquerycurvycorners/) – Hence im closing comments here. Post your contributions either on google code or in the forum.

Found this post useful? Why not buy me a coffee!

Related Entries

307 Responses to “Anti-aliased Rounded corners with JQuery”

RSS feed for comments on this post.

  1. Niels says:

    @Jakobud:
    I have no broken functionality in FF3…

    And in IE7 you will get the error, but only when you make the two top or the two bottom corners have radius 0 at the same time (so create rounded corners at the top and not at the bottom or visa-versa) AND set a border for your element.

    I happens because (topMaxRadius-borderWidth) or (botMaxRadius-borderWidth) evaluates to a negative value leading to a double minus sign in

    <strong>”-”</strong> + (botMaxRadius-borderWidth)

    Comment made on March 12, 2009 at 10:44 pm

  2. VN Webdesigner says:

    I got some problems with this plugin:

    1. My client site current play with Jquery 1.3.1, so the problem is this plugin doesn’t run well on Jquery 1.3.x

    2. When I play this plugin, some css to be changed automatically, such as position move up, absolute position changed to relative position.

    Can this be resolved?

    Thanks!

    Comment made on March 13, 2009 at 5:00 am

  3. Niels says:

    @VN Webdesigner:

    With regard to point 1 take a look at post 326 by Bruno. That should resolve your issues with jQuery 1.3.x.

    Comment made on March 13, 2009 at 10:31 am

  4. Jakobud says:

    Anyone have any clue why I get the following pink background color show through when I add borders to my DIVs?

    http://img3.imageshack.us/my.php?image=roundedcornerpink.jpg

    Comment made on March 17, 2009 at 4:36 am

  5. Rodrigo Barba says:

    I think found a bug:

    I’m in debian + FF3 + JQuery 1.3.2 + Curvy Corner 1.8.1 and when I use the $.corner() in a page with a form, the option ’save password’ of FF not work!

    Comment made on March 17, 2009 at 6:57 pm

  6. Jordan says:

    The problem is not with the css zoom, its the jquery syntax.

    $($$ +” *”).css(“zoom”,”normal”);

    ^^ in that line the “$$” is already a jQuery object, so this should translate to something like $($(’someElement’) +” *”), which is a big no-no.

    Solution:
    $(“*”, $$).css(“zoom”,”normal”);

    OR

    $$.children(“*”).css(“zoom”,”normal”);

    Comment made on March 18, 2009 at 4:27 pm

  7. Scrambler says:

    i’m using:
    jquery: 1.3.2
    JQuery Curvy Corners: 1.81
    with patch:
    $($$ +” *”).css(”zoom”,”normal”);
    to
    $(”*”, $$).css(”zoom”,”normal”);

    my html:

    my css:

    cont
    {
    background-color: #cc0000;
    padding: 20 0 20 20;
    width: 600px;
    border: solid 5px #000000;
    }

    and see this error

    http://s2.subirimagenes.com/otros/2185822corners.jpg

    have any solution for this problem?

    Comment made on March 18, 2009 at 10:23 pm

  8. Zanch says:

    JQuery 1.3.2 + curvy corners 1.8 doesn’t work in internet explorer 6, 7, 8 … that’s all I tested it in. Firefox works fine.

    Comment made on March 18, 2009 at 11:45 pm

  9. Scrambler says:

    Zanch, i have test with JQuery 1.2.4 and also fails :S

    Comment made on March 19, 2009 at 11:49 am

  10. Scrambler says:

    Sorry,I insert this tags and WORK!!!!

    Comment made on March 19, 2009 at 12:54 pm

  11. Chris says:

    I know that this is probably a stupid question, but I seem to be stupid when trying to use this plugin.

    When I implement this, a bottom-margin that was 10 turns into a margin the is about 60.

    Is there something I need to do to enforce margins/paddings?

    Thanks,
    Chris

    Comment made on March 19, 2009 at 9:34 pm

  12. Mike Jolley says:

    Im now uploading a new beta based on Cuvey Corners 2 – stay tuned and Ill make a post when its up.

    Comment made on March 20, 2009 at 4:47 pm

  13. Nick says:

    If anyone has a little time, I could use some help implementing CurvyCorners correctly. I’m using jQuery 1.2.6 and 1.8.1 of the plugin. Having no luck getting it to work in IE6. Works correctly in Safari and FF. One specific question: Do the element styles have to be inline for it to work properly?

    Thanks in advance to the generous soul who might be able to help.

    Comment made on March 23, 2009 at 2:03 pm

  14. Jorge Mera says:

    check this http://blue-anvil.com/archives/jquery-curvy-corners-2-early-beta-available is compatible with explorer 8 and jQuery 1.3.2 , if used pandding attention must be greater than or equal to the size of the curve

    Comment made on March 31, 2009 at 1:29 pm

  15. Dan says:

    hy i like the script but i`m having some problems using it.. exactly how do i set it up? i can`t figure that out

    Comment made on April 3, 2009 at 7:45 am

  16. Sean says:

    @gremki

    Hey gremki… and all other readers,
    I tried to find:
    $($$ +" *").css("zoom","normal");
    and couldn’t, I then did a search for " *" in the jquery.curvycorners.packed.js (ver. 1.8.1) and found this:
    $(c+" *").css("zoom","normal")
    instead.

    I then just switch to this:
    $("*", c).css("zoom","normal")
    and it fixed the error I was getting in IE6 & 7.

    Tested in IE6 (Stand alone from Multiple IE) & IE7 with
    jquery-1.3.min.js

    Good luck :)

    Your friendly neighbourhood,
    Smccullough

    Comment made on April 13, 2009 at 8:34 pm

  17. Smccullough says:

    UPDATE:
    Works with jquery-1.3.2.min.js…. both IE6 & 7

    Comment made on April 13, 2009 at 9:25 pm

  18. Chetan Jethwa says:

    Hi, I am having a problem using curvycorners with jQuery 1.3.2 in IE 6/7/8, getting error uncaught exception

    Comment made on April 22, 2009 at 9:37 am

  19. Chetan Jethwa says:

    Please ignore above comment, found answer on Smccullough’s blog, thanks

    Comment made on April 22, 2009 at 9:46 am

  20. Benjamin says:

    Tried extracting, but had trouble doing so. Seems that the scripts or other content in the .zip file relating to __MACOSX.

    Bottom line… ‘jquery.curvycorners.min’ is the only one that unpacked.

    Any suggestions? Different .zip/extraction program?

    @_@

    Comment made on April 24, 2009 at 10:25 pm

  21. Craig says:

    Thanks for the plugin!
    Saves me heaps of time on a regular basis!

    And thanks to Smccullough for the bug fix, no more uncaught exceptions for me!

    Comment made on April 27, 2009 at 1:43 am

  22. Jan says:

    @Smccullough: This fixed when you have all corners rounded, but I still got it when i do this:

    $('#header').corner( {
    tl: false,
    tr: false,
    bl: { radius: 8 },
    br: { radius: 8 } });

    Even if i try radius 0 it doesn’t work

    Comment made on May 5, 2009 at 11:34 am

  23. Smccullough says:

    @Jan

    I couldn’t seem to replica your issue you are having?
    I copied and pasted verbatim with no errors:

    $(document).ready(function()
    {
    /* Round corner */

    $('div.rounded').corner( {
    tl: false,
    tr: false,
    bl: { radius: 8 },
    br: { radius: 8 }
    });
    });

    What exactly is your setup?
    Browser: IE6/IE7 (/IE8, I haven’t test 8 yet)?
    jQuery version?
    In what order are you adding your script includes?

    You can post a response here or over at my blog (I’ll be able to response to you quicker if it’s on mine, simple because I’ll get an email notice)

    Hope I can help! :)

    Your friendly neighbourhood,
    Smccullough

    Comment made on May 6, 2009 at 2:26 pm

  24. Tony says:

    These things aren’t working on IE8.

    Comment made on May 16, 2009 at 3:56 pm

  25. Leanne says:

    Hi there, I was wondering if there’ll be an ie8 fix coming out soon? I am starting to reeeeally hate ie8.. :X

    Comment made on May 26, 2009 at 11:49 am

The comments are closed.

About this site

Blue Anvil is the online web design journal & portfolio of , a web designer from Norfolk, England. Read More »
ThemeSlice
  • Featured work - More

    • Beefjack
    • Integrity
    • theotaku.com
  • Latest Tweet - More

    • Would be nice is people showed more love for MiniCard by rating it on wordpress.org http://wordpress.org/extend/themes/minicard
  • Out of the blue - More

    • MiniCard 1.1.7 Update

      I have just uploaded 1.1.7 of MiniCard here and to the WordPress theme directory. This updates includes:

      • New networks; xing, gowalla, yelp, foursquare, mobileme, google buzz
      • A way to change link text and define multiple links of the same network
      • A way to define your own custom links + icons
      • Improved admin panel

      Hope you like it, and don’t forget you can show your support by purchasing the premium pack from here.

    • Switched: From Shared to VPS

      It’s been about two weeks now since I made the transition from a shared reseller hosting account to a VPS (Virtual Private Server) account – impressions so far, excellent performance but fiddly to configure.

      The reason I wanted to change from shared hosting was the fact the server was always being hacked (even though ALL my scripts were secure), there was frequent downtime, support blamed me for problems every time, and it was slow as hell.

      Those used to a shared hosting environment would probably not know where to start when faced with configuring a VPS. Luckily, a lot of it was pre-configured when I received my account – certainly some of the major security holes were patched. I was not satisfied with those however. As a victim of hacking in the past (previous host swears it was not there fault, something I don’t believe) I took extra care to secure it as a much I could – configuring brute force detection, the firewall, installing mod security (excellent rules for that here: http://www.atomicorp.com/wiki/index.php/Atomic_ModSecurity_Rules) and going though multiple guides (like this one: http://www.webhostingtalk.com/showthread.php?t=468168) with a fine-tooth comb.

      The result? My pages are loading at least 6 times faster, I have had no down time (or at least have not noticed any), and I feel in control and happy. No longer am I at the mercy of shared hosts :)

      If your interested, I chose ServInt as my provider as they offered a great deal, as well as being a managed service (so I’m not on my own if I screw things up). I was tempted by the bells and whistles of Media Temple, but felt the ServInt service was better value.

    • Download Monitor 3.2.2 Maintenance Release

      Download Monitor has received some more love and has been updated. Here’s the change log from the new version:

      • Small bugfix in uploader.php – cat ID
      • Changed stats graph calculation – thanks lggemini
      • Changes to headers in download.php to avoid caching
      • File Browser fixes – $root was clashing with something….
      • exclude_cat works in all sections of download_page now
      • Removed hardcoding of /uploads/
      • Added action to download.php – should be able to use it to stop a download if you want – maybe limiting downloads per day or something? Whatever you want…
      • Made it so if you post new file on ‘edit’ screen, the post date is updated.
      • Fixed the ‘blank meta’ section which blanks out custom field values when nothing is set.
      • Moved ‘allow_url_fopen’ check.
      • Someone said downloads don’t work with spaces in the name. They do! Wasting my time sonny…
      • All work and no play make jolley a dull boy
      • Had to rename capabilities so they work. Apologies if you have to set this up again! Cheers to Mark Dingemanse.
      • {category_ID} custom format tag added. Useful if you want to send someone to its category on the DL page I guess. Also added {category_other} so when no category is set “other” is shown – this is because the download page can show an ‘other’ section if you want it to.
      • You can now manually edit the post date on the edit download screen.

      If you have edited capabilities for download monitor user permissions, you’ll have to again sorry! This is because I named them too long. Also, you should check your forced downloads still work because there was a logic error meaning they may not have been forced after-all…

      Enjoy.

    • Mahousive update to Download Monitor (3.2)

      Today I completed the update for the Wordpress Download Monitor Plugin – many tweaks, fixes, and features added. There were no changes to the database structure so people upgrading should be fine. Here is the list from the change log:

      • {user} tag added for custom formats
      • ‘autop’ option fix
      • Download page buttons applied with CSS so they are easier to customise/translate.
      • Fix for pagination bug after editing a download
      • Category output fix on edit downloads screen
      • Category urls on download page use ID rather than name to prevent errors when cats have the same names.
      • exclude_cat added to download_page shortcode
      • Localised ‘hits’ ‘date’ ‘title’ on download page
      • Option to disable the download logging
      • Read file ‘chunked’ some people found large files were corrupted so this should help (fingers crossed)
      • Added show_tags option to download page – displays x amount of tags on the download page.
      • File Browser root setting and download.php logic/mime types modified thanks to Jim Isaacs (jidd.jimisaacs.com)
      • Interface Improvements
      • Bulk edit categories, custom fields, tags, member only downloads
      • Added roles for download monitor admin – should be able to use with a role manager plugin if you want anyone other than admin to access the admin section e.g. http://wordpress.org/extend/plugins/capsman/
      • Change redirect after add
      • Edit Cat names/parents
      • Dedicated tags and thumbnails fields (they still use meta table though)

      And yes, those category link bugs are fixed at long last, and you can edit category names finally. Phew!