Skip to content

Instantly share code, notes, and snippets.

@gisu
Created August 11, 2013 09:19
Show Gist options
  • Save gisu/6204136 to your computer and use it in GitHub Desktop.
Save gisu/6204136 to your computer and use it in GitHub Desktop.
Shorthand Mixin to include the Size (width and/or height)
//**
// 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment