gpt4 book ai didi

css - 我如何用 sass 简化这个 css?

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

我有一个 css 文件,我想用 sass 简化它,一些片段如下:

.slick-prev, .slick-next {
height: 30px !important;
}
.slick-prev:before, .slick-next:before {
color: #fff !important;
font-size: 30px !important;
}
.slick-prev:before {
content: "\f104" !important;
font-family: "FontAwesome" !important;
}
.slick-next:before {
content: "\f105" !important;
font-family: "FontAwesome" !important;
}

所以,区别只在于content: "\f104",所以我试着简化一下:

.slick-prev, .slick-next {
height: 30px !important;

&:before {
color: #fff important;
font-size: 30px !important;

// how can I write here?
}
}

如何判断parent是.slick-next:before还是.slick-prev:before

最佳答案

How can I judge the parent is .slick-next:before or .slick-prev:before?

你不能。

这是尽可能简化的:

.slick-prev, .slick-next {
height: 30px !important;

&:before {
color: #fff !important;
font-size: 30px !important;
font-family: "FontAwesome" !important;
}
}
.slick-prev:before {
content: "\f104" !important;
}
.slick-next:before {
content: "\f105" !important;
}

关于css - 我如何用 sass 简化这个 css?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28184116/

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