Sha256: 3ba5db92bd2785daf8df89c4ad7d909690228e51a61081a73a85ee3f799e9bf2

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

@charset "UTF-8";

/// Provides a quick method for setting an element’s position. Use a `null` value to “skip” a side.
///
/// @param {position} $position [relative]
/// A CSS position value
///
/// @param {arglist} $coordinates [null]
/// List of lengths, defined as CSS shorthand
///
/// @example scss
/// .element {
///   @include position(absolute, 0 null null 10em);
/// }
///
/// @example css
/// .element {
///   left: 10em;
///   position: absolute;
///   top: 0;
/// }
///
/// @require {function} is-length
///
/// @require {function} unpack

@mixin position($position: relative, $coordinates: null) {
  @if type-of($position) == list {
    $coordinates: $position;
    $position: relative;
  }

  $coordinates: unpack($coordinates);

  $offsets: (
    top:    nth($coordinates, 1),
    right:  nth($coordinates, 2),
    bottom: nth($coordinates, 3),
    left:   nth($coordinates, 4)
  );

  position: $position;

  @each $offset, $value in $offsets {
    @if is-length($value) {
      #{$offset}: $value;
    }
  }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bourbon-5.0.0.alpha.0 core/bourbon/addons/_position.scss