views:

58

answers:

4

If my css is:

border-bottom-right-radius: 20px;

is there a JavaScript library that will convert it to

-moz-border-radius-bottomright: 20px;

automatically if it detects a user agent that is a mozilla browser, example: Firefox?

+1  A: 

Give Modernizr a look.

treeface
Eh? How is this relevant? Modernizr detects support, not which version of the property is supported. And even then, aren't you still going to need to specify the `-moz` version?
Yi Jiang
I don't understand how this is relevant either.
codeinthehole
+2  A: 

With Sass and Compass you can use mixins which set browser specific rules automatically. This is what you probably need.

There is also another similar library - Less, but I haven't tried it yet.

Igor Pavelek
+1  A: 

Why not just add all webkit and mozilla border declarations and be done with it.

-webkit-border-radius: 1px; -moz-border-radius: 1px; border-radius: 1px;

http://border-radius.com/

woodscreative
Because having the css 3 times larger than it needs to be is icky.
cf_PhillipSenn
Expanding one declaration won't break the bank for such a trivial task.
woodscreative
+1  A: 

This is isn't a JavaScript solution, but LESS CSS can achieve this through use of 'functions'. LESS CSS works using either Ruby, ASP or PHP.

Soon, you will be able to use LESS with JavaScript. See less.js for info. Apparently this will form LESS 2.0

First define your function:

@border-radius(@radius:10px) {
  -webkit-border-radius: @radius;
  border-radius: @radius;
  -moz-border-radius: @radius;
}

Then reference it:

E.g.

#some-id {
  @border-radius;
}

or

#some-id {
  @border-radius(210px);
}
codeinthehole