Skip to content

Instantly share code, notes, and snippets.

@cscottmills
Last active August 10, 2018 14:47
Show Gist options
  • Save cscottmills/6454719 to your computer and use it in GitHub Desktop.
Save cscottmills/6454719 to your computer and use it in GitHub Desktop.
This is the SCSS mixin I've been using to style elements whose background color extends to the edges of the viewport.
// Full bleed
// $direction accepts 'up', 'down' or 'none';
// NB using 'up' or 'down' causes the shadow to extend
// to (and beyond) the top or bottom of the viewport
// Only use 'none' on relatively wide elements,
// and set $width to the width of the element
// --------------------------
@mixin full-bleed($color, $direction: none, $width: 400em) {
@if $color == 'none' {
box-shadow: none;
background-color: transparent;
}
@else {
background-color: $color;
@if $direction == none {
box-shadow: -$width 0 0 0 $color, $width 0 0 0 $color, (-$width * 2) 0 0 0 $color, ($width * 2) 0 0 0 $color;
}
@if $direction == down {
box-shadow: 0 $width 0 $width $color;
}
@if $direction == up {
box-shadow: 0 (-$width) 0 $width $color;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment