【发布时间】:2020-03-19 07:10:21
【问题描述】:
我找不到在 sass 中实现所需内容的方法,您可以帮助我了解这一点。
假设这是代码。
p, span {
font-size: 12px;
// other styles
&:hover {
color: blue;
}
}
我需要的是一种为这两个选择器中的每一个添加不同颜色的悬停颜色的方法,假设 p 元素为蓝色,跨度为红色,目前我是这样做的:
p, span {
font-size: 12px;
// other styles
}
p:hover {
color: blue;
}
span:hover {
color: red;
}
这里的问题是选择器的重复,这似乎不是一个好习惯,我正在考虑这样的事情或任何类似的方式:
p, span {
font-size: 12px;
// other styles
&:first-selector:hover {
color: blue;
}
&:second-selector:hover {
color: red;
}
}
提前致谢。
【问题讨论】:
标签: sass css-selectors dry