开发者

Less - the dynamic stylesheet language?

While googling around for doing more css with less writing and I found this -开发者_运维问答 http://lesscss.org/

Has anybody tried it and is it working under IE6+, Firefox 3+, Chrome, Safari, Opera and all of the standard web browsers we all use?

Thanks in advance :)


http://leafo.net/lessphp/

This is the PHP version of the preprocessor. You create the .less file and upload it to the site. The preprocessor does the rest. Works in any browser because the browser only receives the processed CSS file, not the LESS one. All you need to do is add something like this in your index.php:

require_once 'lessc.inc.php';
try {
    lessc::ccompile(PATH_TO_STYLES.'/style.less', PATH_TO_STYLES.'/style.less.css');
} catch (exception $ex) {
    exit('lessc fatal error:<br />'.$ex->getMessage());
}

and then simply use style.less.css as your site's stylesheet.


You can generate the css server side, or use LESS.js, in the first case, the client is not even aware of the LESS origin of the style, so it's just like css (doesn't rely on client js).


As long as javascript is enabled yes, as there is a js script added after the stylesheet link that helps display it in ie6+ and all other mainstream browsers.

If you are also planning on accomodating users who don't have javascript enabled you can do the processing server side, I haven't done this however, so can't vouch for this method.

Sam


I have tried LessCSS and a range of other likewise alternatives, but settled on SASS (SCSS) - it can be precompiled using a small Ruby Gem which makes it super easy and fast to use in development. The integration to Ruby is a nice plus when working with e.g. Rails if u do that stuff.

http://sass-lang.com/ - use it with the Compass CSS framework (http://compass-style.org/) and you got a pretty badass setup!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜