Rounded Corners With Rico

I’ve seen and tried a ton of HTML/CSS/JavaScript tricks and hacks to get rounded corners on DIV elements. So far I have found that the easist way to get rounded corners on divs is by using the Rico JavaScript framework. To demonstrate this in code let me define a snippet of HTML:

<DIV id=”mydiv” style=”background-color: #FFE6BF”>
some text
</DIV>

To make the DIV element have rounded corners just execute the following bit of JavaScript, perhaps in the document.onload event method:

Rico.Corner.round(’mydiv’);

You can also pass in some additional options to Rico’s round function which indicates which corner(s) to round. Here is another example which rounds only the top-right and bottom-left corners:

Rico.Corner.round(’mydiv’, {corners:’tr bl’});

And of course, br and tl also work.

As a convinience, you can round the corners of multiple elements at once. To round all DIV elements that use a given class use the following JavaScript:

new Rico.Effect.Round(’div’, ’roundCssClass’);

With the above JavaScript, only those DIV element that use the CSS class roundCssClass will be rounded off.

Technorati Tags: , , , ,

Enjoy. Share. Be Happy.
  • Twitter
  • Facebook
  • StumbleUpon
  • del.icio.us
  • Tumblr
  • Google Bookmarks
  • FriendFeed
  • Yahoo! Buzz
  • Reddit
  • Digg
  • HackerNews
  • Suggest to Techmeme via Twitter
  • LinkedIn
  • Ping.fm
  • Identi.ca
  • Mixx
  • Furl

Related posts:

  1. Unobtrusive JavaScript with Prototype and Behavior
  2. Style And Class
  3. JavaScript FX
  4. TechKnow Year In Review 2006
  5. jQuery Library

This entry was posted in CSS, HTML/XML, JavaScript, TechKnow. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. jbschwi
    Posted April 21, 2008 at 1:31 pm | Permalink

    Just for everyone out there who has had a much problems as I have had trying to figure out how to use rico, here is a ‘Hello World’ for rounded corners using rico.

    Rico Rounded Corners

    function init() {
      Rico.Corner.round('roundedCorner', {corners:'all'});
    }
    
    #roundedCorner{
      position:absolute;
      top:10px;
      left:35px;
      width:250px;
      background:#a4a4a5;
    }
    #roundedContent{
      height:100px;
      width:250px;
      padding:5px;
    }
    

    This is a sample of a div with rounded corners. The size is specified in an inner div. IE also requires the width to be specified in the outer div. Sorry about the formatting, if it is messy

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*