2016-04-16 2 views
0

Using the SASS solution as a referenceどのようにこれをLESSで行うのですか?lessを使用してすべてのhタグをターゲットにする

h1, h2, h3, 
h4, h5, h6 { 
    @extend %headings !optional; 
} 

そして、そのようにそれを使用します。最終的に私は、将来的にこれをしたいと思います

.element > %headings { 
    color: red; 
} 

.something { 
    %headings { color: red; } 
} 

それがコンパイルなるように:

.something h1, 
.something h2, 
.something h3 { color: red; } 

答えて

4

リンクされた回答の場合と同様に、 yの方法(例: extend、ループ、parent selectorまたは無名のルールセットを使用)。

// define: 
.headings(@style) { 
    h1, h2, h3, h4, h5, h6 { 
     @style(); 
    } 
} 

// use: 
.something { 
    .headings({ 
     color: red; 
    }); 
} 
:ベストフィットは ruleset as parameter(別名、名前なし/デタッチルールセット)とのミックスインとなり、最後のスニペットについて

関連する問題