views:

53

answers:

1

is such css library that i can use rather than have to manually use special tag for each browsers like below ?

-moz-linear-gradient
-webkit-gradient
-ms-filter: "progid:DXImageTransform.Microsoft.gradient
+2  A: 

I personally don't know of any, but you could set up your CSS files to be parsed with PHP, and then write a function that outputs everything you need. Example:

<?php
function makeBorderRadius($radius) {
    echo "-moz-border-radius: " . $radius . "\n";
    echo "-webkit-border-radius: " . $radius . "\n";
    echo "border-radius: " . $radius . "\n";
}
?>

#mydiv {
    width: 50%;
    background: #000;
    <?php makeBorderRadius(5); ?>
}
derekerdmann
nope, i looking for cross browser css wrapper
cometta
I guess I'm not exactly sure what you mean, then. The final product that gets sent to the browser has to be a plain CSS stylesheet - they won't support anything else. Any extra functionality (like what you're looking for) has to be implemented in some kind of server-side processor. That's what frameworks like LESS (which uses Ruby) do.
derekerdmann
@derekerdmann, that's quite a nice solution. It might be tricky to work with different/individual `border-radius` values for each corner though. +1
David Thomas
@ricebowl Thanks. I don't think it'd be too much work to write a similar function that takes 4 arguments and outputs all the specific corners; it'd just be quite a bit longer. Too bad PHP doesn't support function overloading, because this would be a great use for it.
derekerdmann