Rounding corners with JavaScript has a long history. Everything started on 16th of March 2005 with Nifty Corners and loads of other libs followed.
RUZEE.ShadedBorder itself is the successor of RUZEE.Borders, which was the most feature-rich round corners library out there. But it wasn’t quite easy to use, was slow, had some browser compatibility problems, etc.
ShadedBorders removes most of these limitations and comes with the following features:
- JavaScript-only Photoshop(tm)-like rendering without external images
- Round corners
- Drop shadows
- Glow effects
- Gradient backgrounds
- Graceful degradation - will look ok if JavaScript is turned off
- Borders with different widths and semi-transparency
- Full support for liquid designs
- Anti-Aliasing
- On-hover support
- Disable some of the corners, e.g. bottom-left
- Change borders on-the-fly
- Real transparency - looks perfect on any background
- Cross-Browser: Firefox, Internet Explorer (>=6.0), Safari, Opera (>=9.0)
- Non-obstrusive
- Leight-weight (8.8KB uncompressed)
- Fast (0.5s for the example on a 2.2GHz machine)
- No JavaScript library dependencies
Have a look at the full-featured example, the simple example, or just download the whole library as a ZIP archive (MIT licensed).
Version History
- 2007-12-04 - v0.6.1: Fix transparency on IE7
- 2007-12-02 - v0.6: Semi-transparent fat borders (thanks Ryan) and IE6 hover fixes (thanks NewTrax)
- 2007-10-23 - v0.5: More robust DIV creation, add split borders example for headline/content (for Virsir)
- 2007-10-21 - v0.4: Add graceful degradation, simplify usage, fix IE7(?)
- 2007-10-20 - v0.3: Gradient background support, speed improvements
- 2007-03-27 - v0.2: Fix IE: check boxes inside tables were disappearing
- 2007-03-25 - v0.1: Initial release
How-to
Some steps are required to make your page use ShadedBorder:
Include ShadedBorder to your HTML header section:
<script src="shadedborder.js" type="text/javascript"></script>
Next, define an element you want to round. It is important that it does not directly contain text nodes, i.e. text must always be wrapped inside an HTML element (the “p” in this example):
<div id="round_me">
<p>I want to be rounded!</p>
</div>
Then, in the header section, create the border object. You can define the radius of the round corners, the radius of the drop shadow and the width of the border.
var border = RUZEE.ShadedBorder.create({ corner:8, shadow:16, border:2 });
Note that all parameters are optional, as long as you at least specify one of them. You may also define, which corners/edges should not be rounded. Have a look at the simple example source code for details.
The last thing to do is, to add some JavaScript code directly at the end of the HTML Body which will render the border around the element with the ID “round_me”:
...
<script type="text/javascript">
border.render('round_me');
</script>
The radiuses and widths you specified for the border in the header section are one way of customization. The other way is to change colors. You do this in your CSS file:
#round_me, #round_me .sb-inner { background:red; }
#round_me .sb-shadow { background:blue; }
#round_me .sb-border { background:green; }
This will give your border a red “inner-style”, a blue shadow and a green border - don’t ever use this color combination - it will look extremely ugly ![]()
The first line is important for graceful degradation (new from v0.4 on): the background for your .sb-inner class must also be set on the element itself - but only for .sb-inner, NOT for .sb-shadow or .sb-border!
Adding some hover effect also happens in your CSS file. The following code snippet will change the “inner-style” of your border to purple, once you hover with your mouse over the #round_me element (hey purple will make this beast look even uglier - yuk!).
#round_me:hover, #round_me:hover .sb-inner { background:purple; }
Of course, this will work with “.sb-border” and “.sb-shadow” as well.
Tips
You can use RUZEE.ShadedBorder with the JavaScript library of your choice to get support for CSS-Selectors (e.g. using Prototype, jQuery, etc.). Here’s an example using the $$ function of Prototype to round all child elements of the element with the ID “header” that have the class “tab”:
border.render($$('#header .tab'));
Limitations
- Safari 2 seems to get pretty slow when showing ShadedBorder. I’m looking for people with a Mac and some JavaScript knowledge to speed things up. If you feel like you can help, please contact me via my contact form. Thanks!
- Since a ShadedBorder adds DIV elements to the element you round, those elements cannot be UL, OL, TABLE, TR, etc.. Allowed are DIV, LI, TD, TH, i.e. those elements that are allowed to directly contain DIV elements.
Hi, the name's Steffen and I'm writing about the Web, programming
and all those things coming to my mind. Enjoy your stay.
June 2nd, 2008 at 17:47
[...] distintas técnicas para redondear bordes, podemos hacerlo con CSS, con Javascript utilizando Ruzee o Nifty Corners, o utilizando algún editor de imágenes, los cuales quizás son [...]
June 12th, 2008 at 3:38
Hi Steffen, this is a very nice rounded corners script. It seems to come the closest to what I want to achieve, so hopefully you can give me a suggestion. I’m looking to create rounded corners as this does, but with a bottom aligned background image (instead of top aligned as this script does). Is this possible with this script, or do you have a suggestion for a solution?
Thanks!
Gabe
June 12th, 2008 at 6:45
Hm, for some reason I couldn’t get the full comment list until I posted. Now that I’ve read them all I see this has been asked, doesn’t look like it’s something that can be done with this script. Can anyone recommend a good solution then (for fluid rounded corners with a bottom aligned background image)?
June 12th, 2008 at 8:25
like it ,just a little slowly.
June 13th, 2008 at 15:15
hi, great scripting!. but I have several problems with the upgrades:
I was using version 0.3 and was very happy with it.
now with the version 0.6 I am lost, I would like to have SAME design as it was implemented in version 0.3, but see soo many complications:
i.e
in the ruzee is used with UL LI tags and is placed inside table nothing is shown.
also it does not work properly with IE 6.0+, 7 is fine.
please explain how can i use current version of the ruzee shaded border in order to arrive to the SAME look as it was in version 0.3?
thank you
June 19th, 2008 at 12:47
[...] 角丸コーナーや影付きドロップシャドウをJavaScriptとCSSだけで作成できるShadedBorderですが、 何故か縦長のページの時に、背景が途切れてしまうという現象が起こりました。 [...]
June 21st, 2008 at 14:00
Hi Steffen
Great script. Couple questions though - one, I don’t seem to be able to have floated DIVs inside. I wanted to use the transparent border box for a container, and inside have 2 DIVs, one floated left and one right. But it won’t work. Any ideas? Second, if I had the transparent border on each DIV instead, so there was 2 boxes, or columns, side by side, could I get them to have equal heights? Maybe add an equal columns script or something?
June 21st, 2008 at 23:52
Hey, I have a simple page that *always* crashes IE7. (I tried on a couple of different machines already. It works well in Firefox though.)
For some reason, if I use both and in a , then it would crash. If I remove either or remove then IE no longer crashes.
Here is the page, hopefully you can view it properly in the comments.
TITLE
My Caption
ANAME
$(document).ready(function() {
var shadow = RUZEE.ShadedBorder.create({ corner:8, shadow:16, border:0 });
shadow.render($(”.module”));
});
June 21st, 2008 at 23:56
Sorry about the previous posts.
Here is the snippet:
http://snippetsnap.com/work_rooms/12247?snippet=16419
June 22nd, 2008 at 0:07
Sorry, I am having problems with the comment system, so I repeat myself here just in case.
I have a simple page using Ruzee.ShadedBorder that consistently crashes IE7. I tried this on a couple of machines with the same results. It works fine in firefox though.
The problem happens when I have a “caption” and “a name” tag inside a table. The table is inside a div that I applied borders on. If I remove either the “caption” or “a name” tag, then the page no longer crashes.
Here is the snippet for your reference:
http://snippetsnap.com/snippets/16420-New-Snippet
Sorry again for the previous posts.
< Prev 1 … 29 30 31 … 33 Next > Show All
Leave a Reply