ricardozea
9/24/2013 - 4:44 AM

Utility mixin to easily set the width and height of an element. From: http://codepen.io/jackiebackwards/pen/vlrsq

Utility mixin to easily set the width and height of an element. From: http://codepen.io/jackiebackwards/pen/vlrsq

/**
  * Utility mixin to easily set the width and height of an element.
  * Makes perfect squares easier to create and maintain.
  *
  * http://codepen.io/jackiebackwards/pen/vlrsq
  */

@mixin size( $width, $height: false ) {
  width: $width;
  
  @if( $height ) {
    height: $height;
  }
  @else {
    height: $width;
  }  
}

//Usage
.selector {
  @include size(10px);
}

.selector2 {
  @include size(10px,50px);
}