如何通过sass继承多个类 [英] how to inheritance multiples class through sass
本文介绍了如何通过sass继承多个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have a scenario in sass
.A{
background-color: red;
Padding :20px;
h4{ padding-bottom :20px;}
}
// another class
.B{
background-color : blue;
padding : 20px
h4{ padding-bottom:20px}
}
问题:如何在 SASS 中将 padding 和 h4 组合在一起而不重复 padding 和 h4 属性
Question: how can i combine padding and h4 together in SASS without to repeating padding and h4 properties
推荐答案
最直接的方式是使用@extend
.
%common_properties {
padding: 20px;
h4 {
padding-bottom: 20px;
}
}
.a {
@extend %common_properties;
background-color: red;
}
.b {
@extend %common_properties;
background-color: blue;
}
这篇关于如何通过sass继承多个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文