Last Updated: February 25, 2016
·
1.228K
· gisugosu

SASS Size Shorthand

A Sass mixin to include the Size of an Element.

//**
// Mixin: size 
// Shorthand for insert Dimensions. Default in PX, opt in Percent
// Entering only one Value the Dimension Squared, with two Values
// the width and height are written.
//
// @mixin     size
// @param     $size {number} Width and or Height
// @usage     +size($size, $value)
// @eg        +size(200 100)
//**
@mixin size($size)
  @if length($size) == 2
    $width  : nth($size,1)
    $height : nth($size,2)

    @if unitless($width)
      $width: $width + 0px
    @if unitless($height)
      $height: $height + 0px

    height: $height
    width: $width

  @if length($size) == 1
    @if unitless($size)
      $size: $size + 0px

    height: $size
    width: $size