Sass 嵌套下怎么把伪类写成组合选择器的形式??

有这样一段代码:

a {
  &:active {
  background-color: transparent !important;
  border-bottom: 0;
  }
  &:focus {
    background-color: transparent !important;
    border-bottom: 0;
  }
  &:hover {
    background-color: transparent !important;
    border-bottom: 0;
  }
}

想把 active focus hover 写在一起,消除重复,可是我按照组合选择器的写法编译器报错:

// 编译报错
a {
  &:active,&:focus,&:hover {
  background-color: transparent !important;
  border-bottom: 0;
  }
}

有什么好的重构方法么?

阅读 7k
1 个回答

.style{
background-color: transparent !important;
border-bottom: 0;
}
a {
&:active,
&:focus,
&:hover {

@extend .style;

}
}

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题