SASS type-of 函数

今儿写个type-of,算是备忘录吧。

1.number

type-of(0)                    // number
type-of(1px)                  // number

2.string

type-of(a)                    // string
type-of("a")                  // string

3.bool

type-of(true)                 // bool
type-of(0<1)                  // bool

4.color

type-of(rgba(1,2,3,.3))       // color
type-of(rgb(1,2,3))           // color
type-of(#fff)                 // color
type-of(red)                  // color

5.list(sass.list=js.array)

// 需要加括号
type-of((1px,2px,3px))        // list
type-of((1px 2px 3px rgba(0,0,0,.3))) // list

6.map(sass.map=js.json)

type-of((a:1px,b:2px))        // map

7.null

type-of(null)                 // null

注:检测格式,要用字符串

@if type-of(null) == "null" { ... }

 

posted @ 2014-10-20 12:03  ccforeverd  阅读(579)  评论(0编辑  收藏  举报