Skip to content

Instantly share code, notes, and snippets.

@unicornware
Last active January 2, 2021 19:06
Show Gist options
  • Select an option

  • Save unicornware/3dde96af38a9fdb1c933c0a8a28916af to your computer and use it in GitHub Desktop.

Select an option

Save unicornware/3dde96af38a9fdb1c933c0a8a28916af to your computer and use it in GitHub Desktop.
Sass Mixin - Utility classes for removing the margin or padding from the first or last element within a container
/// ----------------------------------------------------------------------------
/// @name spacing-utils-first-last
/// @group mixins
/// ----------------------------------------------------------------------------
/// Generates utility classes for removing the margin or padding from the first
/// or last element within a container.
/// @require {function} breakpoint-infix
/// @require {mixin} breakpoint-up
/// @require {variable} $grid-breakpoints
/// @require {variable} $spacers
@mixin spacing-utils-first-last {
@each $pos in (first, last) {
@each $abbr, $value in (m: margin, p: padding) {
@each $direction, $dir in (b: bottom, l: left, r: right, t: top) {
@each $breakpoint in map-keys($grid-breakpoints) {
@include breakpoint-up($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
.#{$infix}#{$abbr}#{$direction}-0 {
&-#{$pos} > *:#{$pos}-child {
#{$value}-#{$dir}: map-get($spacers, 0) !important;
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment