Sass - Check which kind of value a variable has

前端 未结 2 1212
星月不相逢
星月不相逢 2020-12-14 19:49

Suppose i have a variable:

$var: 5px;

but somewhere in code its value have changed in to possible color, number

2条回答
  •  春和景丽
    2020-12-14 20:24

    From the Sass documentation:

    type_of($value)

    Returns the type of a value.

    Examples:

    type-of(100px)  => number
    type-of(asdf)   => string
    type-of("asdf") => string
    type-of(true)   => bool
    type-of(#fff)   => color
    type-of(blue)   => color
    

    http://sass-lang.com/documentation/Sass/Script/Functions.html#type_of-instance_method

    (note that - and _ is interchangeable in Sass functions).

提交回复
热议问题