在SCSS中包含另一个类 [英] Including another class in SCSS

查看:443
本文介绍了在SCSS中包含另一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的SCSS文件中有这个:

I have this in my SCSS file:

.class-a{
  display: inline-block;
  //some other properties
  &:hover{
   color: darken(#FFFFFF, 10%);
 }  
}

.class-b{

 //Inherite class-a here

 //some properties
}

在class-b中,我想继承所有属性和嵌套声明 A级。这是怎么做到的?我尝试使用 @include class -a ,但这只会在编译时抛出错误。

In class-b, I would like to inherite all properties and nested declarations of class-a. How is this done? I tried using @include class-a, but that just throws an error when compiling.

推荐答案

对于像这样的简单案例,不需要 @mixin @include

Looks like @mixin and @include are not needed for a simple case like this.

可以这样做:

.myclass {
  font-weight: bold;
  font-size: 90px;
}

.myotherclass {
  @extend .myclass;
  color: #000000;
}

这篇关于在SCSS中包含另一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆