CSS rules output by SASS mixin being ignored

不想你离开。 提交于 2019-12-20 06:51:08

问题


A SASS mixin which produces some CSS rules is being ignored. Chrome Dev Tools is showing the rules registered but crossed out and I cannot figure out why. I initially thought there was a conflict of specificity but there are no conflicting rules.

Here is the SASS:

span.icon {
    display: inline-block;
    background-image: url('images/sprite.png');
    background-repeat: no-repeat;

    &.telephone {
        @include sprite('19px', '25px', '-300px 0');
    }
}

Here is the mixin:

@mixin sprite($width, $height, $bg-position) {
    width: $width;
    height: $height;
    background-position: $bg-position;
}

Here is the out output from Chrome Dev Tools

The width, height and background-poisition property is not being specified for that element elsewhere so I don't understand why those rules are being ignored.


回答1:


The browser is ignoring your CSS because it is not valid. The width, height, and background-position properties do not accept strings, they accept lengths (in the case of background-position, a list of lengths).

.foo {
   @include sprite(19px, 25px, -300px 0);
}

Unless you want a string, do not use quotes.



来源:https://stackoverflow.com/questions/23496277/css-rules-output-by-sass-mixin-being-ignored

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!