如何对CSS类设置进行分组
是否可以组合类设置组,类似于@media如何组合设置组?换句话说,与其这样做,不如:如何对CSS类设置进行分组,css,Css,是否可以组合类设置组,类似于@media如何组合设置组?换句话说,与其这样做,不如: h1.subtitle, h2.subtitle, h3.subtitle, h4.subtitle, h5.subtitle, h6.subtitle, .h1.subtitle, .h2.subtitle, .h3.subtitle, .h4.subtitle, .h5.subtitle, .h6.subtitle { margin-top:0; } 我想这样做: .subtitle { h1,
h1.subtitle,
h2.subtitle,
h3.subtitle,
h4.subtitle,
h5.subtitle,
h6.subtitle,
.h1.subtitle,
.h2.subtitle,
.h3.subtitle,
.h4.subtitle,
.h5.subtitle,
.h6.subtitle {
margin-top:0;
}
我想这样做:
.subtitle {
h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
margin-top:0;
}
}
.subtitle h1 {}
.subtitle h2 {}
...
您可以使用或作为预编译器来执行此操作。但它会产生这样的结果:
.subtitle {
h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
margin-top:0;
}
}
.subtitle h1 {}
.subtitle h2 {}
...
否则这是不可能的
注意:您不必在类前面使用类型。您可以在预编译器中使用或执行该操作。但它会产生这样的结果:
.subtitle {
h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
margin-top:0;
}
}
.subtitle h1 {}
.subtitle h2 {}
...
否则这是不可能的
注意:您不必在类前面使用类型。您可以在预编译器中使用或执行该操作。但它会产生这样的结果:
.subtitle {
h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
margin-top:0;
}
}
.subtitle h1 {}
.subtitle h2 {}
...
否则这是不可能的
注意:您不必在类前面使用类型。您可以在预编译器中使用或执行该操作。但它会产生这样的结果:
.subtitle {
h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
margin-top:0;
}
}
.subtitle h1 {}
.subtitle h2 {}
...
否则这是不可能的
注意:您不必在类前面使用类型。对于Sass或更少的类型,您可以这样做
h1,
h2,
h3,
... {
&.subtitle {
margin-top:0;
}
}
这将输出到
h1.subtitle,
h2.subtitle,
h3.subtitle,
... {
margin-top:0;
}
有了Sass或更少,你可以做这样的事情
h1,
h2,
h3,
... {
&.subtitle {
margin-top:0;
}
}
这将输出到
h1.subtitle,
h2.subtitle,
h3.subtitle,
... {
margin-top:0;
}
有了Sass或更少,你可以做这样的事情
h1,
h2,
h3,
... {
&.subtitle {
margin-top:0;
}
}
这将输出到
h1.subtitle,
h2.subtitle,
h3.subtitle,
... {
margin-top:0;
}
有了Sass或更少,你可以做这样的事情
h1,
h2,
h3,
... {
&.subtitle {
margin-top:0;
}
}
这将输出到
h1.subtitle,
h2.subtitle,
h3.subtitle,
... {
margin-top:0;
}
我想在这里使用SCSS,但是这个结果当然不是OP想要的(他想要
h1.subtitle,
),所以即使是SCSS也不能解决它?我想在这里使用SCSS,但是这个结果当然不是OP想要的(他想要h1.subtitle,
),所以即使是SCSS也不能解决它?我想在这里使用SCSS,但是这个结果当然不是OP想要的(他想要h1.subtitle,
),所以即使是SCS也不能解决它?我想在这里使用SCS,但这个结果当然不是OP想要的(他想要h1.subtitle,
),所以即使是SCS也不能解决它?你真的必须这样吗?是否有任何其他元素不是h1-h6(或相应的类)的类“subtitle”,这将阻止您仅使用。subtitle
?如果使用SCSS,您可以这样做,因为我知道您希望以缩写的方式编写规则,所以这正是您可以使用SCSS的方式。否则(你想要的方式)会产生不同的结果。你真的必须这样做吗?是否有任何其他元素不是h1-h6(或相应的类)的类“subtitle”,这将阻止您仅使用。subtitle
?如果使用SCSS,您可以这样做,因为我知道您希望以缩写的方式编写规则,所以这正是您可以使用SCSS的方式。否则(你想要的方式)会产生不同的结果。你真的必须这样做吗?是否有任何其他元素不是h1-h6(或相应的类)的类“subtitle”,这将阻止您仅使用。subtitle
?如果使用SCSS,您可以这样做,因为我知道您希望以缩写的方式编写规则,所以这正是您可以使用SCSS的方式。否则(你想要的方式)会产生不同的结果。你真的必须这样做吗?是否有任何其他元素不是h1-h6(或相应的类)的类“subtitle”,这将阻止您仅使用。subtitle
?如果使用SCSS,您可以这样做,因为我知道您希望以缩写的方式编写规则,所以这正是您可以使用SCSS的方式。否则(你想要的方式)将给出不同的结果。