2015-10-16 68 views
0

普通的编程语言有这样的东西CSS是否有创建更紧凑代码的子面板的方法?

int x, y, z; 

,这样你就不必写出

int x; 
int y; 
int z; 

在CSS中我经常发现自己不必写这样的东西

.some-class h1, .some-class h3, .some-class p { margin-bottom: 1.2em; } 

当它看起来应该像

.some-class (h1, h3, p) { margin-bottom: 1.2em; } 

有没有这样的事情?

+0

您将需要一个CSS预处理器,如[LESS](https://en.wikipedia.org/wiki/Less_(stylesheet_language)#Nesting)做类似的事情。 – jfriend00

+0

或者你可以这样做:.some-class h1,h3,p {margin-bottom:1.2em; } –

+0

@ZiggyVerstrepen这有效吗? –

回答

1

您将需要一个CSS预处理器,它使用缩进显示死者。以下是如何会看在SASS

.some-class { 
    h1, h3, p { 
     color: red; 
    } 
} 
相关问题