Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 如何向我的SASS计算中添加%?_Css_Sass - Fatal编程技术网

Css 如何向我的SASS计算中添加%?

Css 如何向我的SASS计算中添加%?,css,sass,Css,Sass,我正在使用SASS根据元素宽度和容器宽度将宽度维度转换为%,但我的问题是,如果我在计算结束时加上%,我会得到一个错误,有人能告诉我如何解决这个问题吗 @mixin percentageWidth( $elementWidth, $containerWidth ){ width: (($elementWidth/$containerWidth)*100) + %; *width: ((($elementWidth/$containerWidth)*100) - ((0.5/$contain

我正在使用SASS根据元素宽度和容器宽度将宽度维度转换为%,但我的问题是,如果我在计算结束时加上%,我会得到一个错误,有人能告诉我如何解决这个问题吗

@mixin percentageWidth( $elementWidth, $containerWidth ){
  width: (($elementWidth/$containerWidth)*100) + %;
  *width: ((($elementWidth/$containerWidth)*100) - ((0.5/$containerWidth)*100)) + %;
}
根据,您需要将结果乘以
100%
,而不是像添加字符串一样尝试添加
%

width: ($elementWidth/$containerWidth) * 100%;
*width: (($elementWidth/$containerWidth) - (0.5/$containerWidth)) * 100%;
根据,您需要将结果乘以
100%
,而不是像添加字符串一样尝试添加
%

width: ($elementWidth/$containerWidth) * 100%;
*width: (($elementWidth/$containerWidth) - (0.5/$containerWidth)) * 100%;

你不需要那么多父母
a/b*c
而不是
((a/b)*c)
,和
a/b*c-d/e*f
而不是
((a/b)*c)-(d/e)*f))
。谢谢,我如何更新此混音,以便使用不同的属性,如边距、宽度或填充?您不需要所有这些参数
a/b*c
而不是
((a/b)*c)
,和
a/b*c-d/e*f
而不是
((a/b)*c)-(d/e)*f))
。谢谢,我如何更新此混音,以便可以使用不同的属性,如边距、宽度或填充?