gpt4 book ai didi

html - 避免双重写作风格

转载 作者:太空宇宙 更新时间:2023-11-04 11:56:32 25 4
gpt4 key购买 nike

我想知道如果某个元素的某些样式相同并且可能是伪类,我如何避免将某些样式写两次:

.element {
color: #a0c225;
&:hover {
color: #a0c225;
}
&:focus {
color: #a0c225;
}
}

而且我不想在 SASS 中重复颜色 #a0c225

最佳答案

你可以使用 & 来做这样的事情:

.element {
&, &:hover, &:focus {
color: #a0c225;
}
}

编译为:

.element, .element:hover, .element:focus {
color: #a0c225;
}

关于html - 避免双重写作风格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30169425/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com