第4章 高度な機能を覚えてSassを使いこなそう
4-7 Sassのデータタイプについて
データタイプを判別する
.DataTypes:after {
content: quote(type-of(10px));
}
.DataTypes:after {
content: "number";
}
.DataTypes:after {
/* Number型 */
content: quote(type-of(10%));
/* Color型 */
content: quote(type-of(red));
/* String型 */
content: quote(type-of(sans-serif));
/* Boolean型 */
content: quote(type-of(true));
/* List型 */
content: quote(type-of(1.5em 1em 0 2em));
/* Null型 */
content: quote(type-of(null));
}
.DataTypes:after {
/* Number型 */
content: "number";
/* Color型 */
content: "color";
/* String型 */
content: "string";
/* Boolean型 */
content: "bool";
/* List型 */
content: "list";
/* Null型 */
content: "null";
}
@function example($value) {
@if type-of($value) == number {
処理
}
}


