在 SCSS 中,可以使用 'unit()' 函数获取值的单位,使用 'unitless()' 函数获取值是否有单位,使用 'inspect()' 函数获取值的完整表示。

以下是示例代码:

$width: 100px;

// 获取单位
$unit: unit($width); // 输出:px

// 获取值是否有单位
$is_unitless: unitless($width); // 输出:false

// 获取值的完整表示
$value: inspect($width); // 输出:100px
SCSS 获取单位和值:unit(), unitless() 和 inspect() 函数详解

原文地址: https://www.cveoy.top/t/topic/mTro 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录