0

i started using LESS to have a simple tool for creating .css files.

My question is, what is the most common way to handle such css class-construct:

<div id="wrapper">
     <div id="left">
           <h2>Left</h2>
     </div>
     <div id="right">
           <h2>Right</h2>
     </div>
</div>

The boxes #left and #right have exactly the same stylesheet, the h2 in each box should be different.

I would have solved it with this code:

#wrapper {
    #left, #right {
        width:50%;
        float:left;
    }

    #left h2 {
         color:black;
    }

    #right h2 {
         color:red;
    }
}

or you can solve it like this:

.left_right {
    width:50%;
    float:left;
}

#wrapper {

    #left {
        .left_right;

         h2 {
        color:black;
        }
    }

    #right {
          .left_right

           h2 {
        color:red;
        }
    }
}

What is the 'right' way or is it just a personal choice...

P.S: And is there any way to get highlighting in CODA for .less files?

Thanks

4

1 回答 1

0

个人喜好肯定。对我来说,第一个例子更容易阅读并且应该减少 CSS,这毕竟是 LESS 的目的!

至于 CODA 中的语法突出显示,我自己不使用它,或者现在可以访问 Mac,但快速谷歌搜索出现了一些结果。

可以在此处找到一种方式的说明:http: //christophercasper.com/2010/09/less-syntax-highlighting-in-coda/

我还发现有一个 CODA 插件,但现在它已经变成了它自己的应用程序。不确定它有多大用处,但你可以在这里找到它:http: //incident57.com/less/

于 2012-03-08T11:29:28.493 回答