Create rounded corners for DIV elements using Javascript

0

curvyCornersMost websites these days use rounded corners for almost all website elements. Creating rounded corners isn’t easy since it requires creating perfectly aligned images and well, you need to be a photoshop or a GIMP ninja, which I’m definitely not.

So, I went looking for a better solution and found a Javascript which would do the same for me.

curvyCorners (Their capitalization, not mine) is a free JavaScript program that will create on-the-fly rounded corners for any HTML DIV element, that look as good as any graphically created corners.

No image editing, no GIMP, no photoshop Ninja required !

To start using curvyCorners, you need to import the JavaScript in the <head> section of your webpage.

<script src=”curvycorners.js” type=”text/JavaScript”></script>

Then create your DIV tag normally as you would

<DIV id=”NinjaID”></DIV>

Next comes the part where you actually add the Javascript code to handle the rounding of the corners. This should also go in the head section of the webpage.

<script type=”text/JavaScript”>

window.onload = function()
{
settings = {
tl: { radius: 20 },
tr: { radius: 20 },
bl: { radius: 20 },
br: { radius: 20 },
antiAlias: true,
autoPad: false
}

var divObj = document.getElementById(“NinjaDiv”);

var cornersObj = new curvyCorners(settings, divObj);
cornersObj.applyCornersToAll();
}

</script>

That’s all there is to it. The above code will create a nicely rounded DIV with a 20 pixel radius. Change the number after the “radius: ” keyword to change the radius of the circle used to create the corner.

curvyCorners Example

The tl, tr, bl and br keywords stand for the top left, top right, bottom left and bottom right corners. So, you can even have different radiuses for different corners, if you want to.

This example has been taken from the Usage page and they also have lot of other cool tricks that you might be interested in.

curvyCorners works on IE, firefox, Opera and Safari and is supported on both Windows and Mac OS X.

Download curvyCorners

Sharninder:
Programmer, blogger and a geek making a living shifting bits around the Internet. Sharninder is the owner of Geeky Ninja

Related Posts

Leave a Reply

no prescription generic maxalt maxalt generic sale purchase cheap prescription Premarin buy Premarin in the uk Cytotec price buy herbal Activ8 Energy Booster Valtrex with no perscription and delivered over night purchase Maxalt without a prescription online buy Activ8 tablets without rx Activ8 pharmacy purchase Requip online no membership Maxalt purchase online how to buy Amitriptyline without a prescription Amitriptyline in usa buy Nizoral no prescription low cost order no online rx Orlistat purchase xenical without prescription to ship overnight buy Amitriptyline online pills purchase online prescription Amitriptyline Overnight Requip without a perscription order rx free Nizoral buy cheap Nizoral uk Amitriptyline generic where to purchase Amitriptyline no prescription no fees buy Nizoral on line amex cheap Nizoral uk buy Orlistat c o d cheap Premarin usa Premarin without rx buy no online rx Prozac Premarin buy online purchase Premarin without purchasing Maxalt online without prescription canada Proscar Proscar order i want to buy Proscar without a perscription buy brand Prednisone buy Requip 1 mg buy cheapest Lisinoprilbuy no prior prescription Lisinopril purchase Arimidex cod overnight delivery Canadian arimidex cheap purchase Maxalt buy discount Anafranil Endep with free fedex overnight buy Endep fed ex buy generic Endep from india buy Maxalt with american express Amitriptyline online purchase order online Famvir without prescription free fedex delivery Famvir where to buy Famvir no prescription no fees Aricept buy online purchase Aricept without prescription pay cod uk Aricept Aricept buy on line Nizoral without a perscription Nizoral fedex shipping order Nizoral order amex order Endep online buy Endep Online buy Endep us Amitriptyline canada canadian prescriptions Endep buy Endep amex online without rx buy Amitriptyline doctor prescription online Amitriptyline purchase buy Accutane 40 mg on line Canadian 40 mg Accutane diet pills without a perscription buy Activ8 Energy Booster with amex buy genuine Aldactone maxalt shipped by cash on delivery buy Maxalt online no rx order Prednisone online Lisinopril and dexamethasone arimidex with no r x and free shipping buy cheap Anafranil under without rx buy Famvir overnight delivery el Aricept generico buy Aricept overnight where to purchase generic Nizoral online without a rx cheap Endep uk Accutane 40 mg purchase 40 mg Accutane online perscription canadian generic Activ8 no prescription Activ8 generic buy cheapest Nizoralbuy no prior prescription Nizoral
© 2012 Geeky Ninja. All rights reserved.
Proudly designed by Theme Junkie.
VirtuaGirl Free
Watch movies online absolutely free