如何用sass简化这个css?

时间:2015-01-28 03:26:17

标签: css sass compass-sass

我有一个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?
    }
}

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

1 个答案:

答案 0 :(得分:1)

  

如何判断父级是.slick-next:before还是.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;
}