Would be nice if we could support the Drupal way of searching for a xxx-rtl.css.less file when viewing a. rtl page not only for files included by Drupal / theme.info, but also those @import'ed via the less/css @import command.
My current css stack looks like this: style.css.less @import's grid-custom.css.less which in turn @import's semantic.gs.css.less.
In this situation it would be crucial if lessphp processed the rtl versions of the @import'ed files as well. I can't load the grid css files via thze theme.info for the obvious scope reasons.
Current solutions are placing all css.less in one single file plus the corresponding -rtl.css.less file, or using inline
html[dir="rtl"] & {
/* RTL rules */
}
in combination with selectivizr.
Comments
Comment #1
corey.aufang commentedRTL support in LESS is really more of just naming your files with .css.less and letting Drupal handle the rest. So if Drupal does it, LESS can do it, as long as you name end your files with .css.less .
Personally I suggest using the method in the sample you provided. It should only require selectivizr if you need IE6 support as simple attribute selectors are supported by IE7+ http://caniuse.com/#feat=css-sel2
Also, for sanity's sake when maintaining your stylesheets I find it makes more sense, and saves time to use ampersand (&) selectors in LESS.
When you use an ampersand selector, you put the special tweak immediately next to the code that you are tweaking, rather than placing it in an entirely other file. This helps to ensure that when a change is made you can easily see other special changes that also need to be made.
This can be used to effect when targeting versions of IE. Here is the opening tag from HTML5 Boilerplate, which I used elements from in my themes adapted for Drupal:
This allows you to easily target a specific version of IE by doing a style like:
You can place that in any style and it instantly now applies to that version of IE and no other browsers.
Comment #2
derPaolo commentedyup, that's what I ended up doing.
also, for IE6 support, one could add a conditional class like
and select via
.rtl &. only downside is that due to right-to-left stylesheet parsing, this feels more costly thanhtml[dir=rtl].Comment #3
corey.aufang commentedHere's a good reference on CSS selector speed:
http://csswizardry.com/2011/09/writing-efficient-css-selectors/
Comment #4
corey.aufang commentedOops, wrong status.