【问题标题】:What is the correct use of Sass/SCSS mixin arguments in this case?在这种情况下,Sass/SCSS 混合参数的正确用法是什么?
【发布时间】:2014-08-28 03:28:05
【问题描述】:

我在为background-size 属性使用$image-width$image-height 参数时遇到问题。 CSS 仅在我选择将参数写入到位时才有效(如下面代码示例中的注释行所示)。动态版不行。我做错了什么?

除此之外,此代码 sn-p 应仅在设备需要时加载视网膜版本。 在此处阅读更多信息:Media Query Asset Downloading

/* see: http://timkadlec.com/2012/04/media-query-asset-downloading-results/ */
@mixin retina-background($filename, $image-width, $image-height, $extension: ".png") {
    background-image: image-url($filename + $extension);
    height: $image-height;
    width: $image-width;
    @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
    only screen and (min--moz-device-pixel-ratio: 1.5),
    only screen and (-o-min-device-pixel-ratio: 3/2),
    only screen and (min-device-pixel-ratio: 1.5) {
        background-image: image-url($filename + "2x" + $extension);
        //background-size: 213px 21px;
        background-size: $image-width $image-height;
        height: $image-height;
        width: $image-width;
    }
}

【问题讨论】:

  • 刚刚检查了您的代码,它工作正常,background-size 值已到位。

标签: sass mixins


【解决方案1】:

是的,代码运行良好。我忘记在调用函数的参数中分配“px”。所以生成的 CSS 是错误的(没有单位)。多么无用的错误。非常感谢!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-26
    • 1970-01-01
    • 1970-01-01
    • 2018-05-03
    • 1970-01-01
    • 1970-01-01
    • 2013-04-23
    • 2020-11-29
    相关资源
    最近更新 更多