gpt4 book ai didi

css - 如何在字符串中运行 SASS 函数

转载 作者:太空宇宙 更新时间:2023-11-03 18:17:49 24 4
gpt4 key购买 nike

我有一个 sass include,里面有一个 sass 函数,需要在编译之前运行。例如我有这个包括

@include vendor-prefix("transform", "translate3d(0, reduceByHalf(-944px), 0)");

结果是

transform: translate3d(0, reduceByHalf(-944px), 0);

reducebyHalf 未被处理,因为它位于字符串中。下面是 reduceByHalf 函数的样子。

@function reduceByHalf($pxWidth, $negative:false) {

@if $negative {
@return -($pxWidth / 2);
}

@return $pxWidth / 2;
}

如何从字符串中运行 reduceByHalf 以生成正确的值?

一如既往地感谢您的帮助。

最佳答案

试试这个,

@include vendor-prefix("transform", "translate3d(0, #{reduceByHalf(-944px)}, 0)");

关于css - 如何在字符串中运行 SASS 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22446369/

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