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