Sass mixin for same Width and Height

Instead of typing width:200px; height:200px; just type @include size(200px); or @include size(20px,35px);


Demo

Mixin:

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

HTML:

<div class="square"></div>

Usage:

.square { @include size(200px); }

Compiles to:

.square {
  width: 200px;
  height: 200px;
}
    

Created by Ricardo Zea