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

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;
  }
}

有什么好的重构方法么?


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

@extend .style;

}
}

【热门文章】
【热门文章】