Skip to content

Commit

Permalink
Add overflow-auto and overflow-hidden utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
mdo committed Oct 7, 2018
1 parent 2301557 commit 29bd5e3
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
1 change: 1 addition & 0 deletions scss/_utilities.scss
Expand Up @@ -6,6 +6,7 @@
@import "utilities/embed"; @import "utilities/embed";
@import "utilities/flex"; @import "utilities/flex";
@import "utilities/float"; @import "utilities/float";
@import "utilities/overflow";
@import "utilities/position"; @import "utilities/position";
@import "utilities/screenreaders"; @import "utilities/screenreaders";
@import "utilities/shadows"; @import "utilities/shadows";
Expand Down
6 changes: 6 additions & 0 deletions scss/_variables.scss
Expand Up @@ -1001,6 +1001,12 @@ $pre-color: $gray-900 !default;
$pre-scrollable-max-height: 340px !default; $pre-scrollable-max-height: 340px !default;




// Utilities

$overflows: auto, hidden !default;
$positions: static, relative, absolute, fixed, sticky !default;


// Printing // Printing


$print-page-size: a3 !default; $print-page-size: a3 !default;
Expand Down
5 changes: 5 additions & 0 deletions scss/utilities/_overflow.scss
@@ -0,0 +1,5 @@
// stylelint-disable declaration-no-important

@each $value in $overflows {
.overflow-#{$value} { overflow: $value !important; }
}
5 changes: 0 additions & 5 deletions scss/utilities/_position.scss
@@ -1,11 +1,6 @@
// stylelint-disable declaration-no-important // stylelint-disable declaration-no-important


// Common values // Common values

// Sass list not in variables since it's not intended for customization.
// stylelint-disable-next-line scss/dollar-variable-default
$positions: static, relative, absolute, fixed, sticky;

@each $position in $positions { @each $position in $positions {
.position-#{$position} { position: $position !important; } .position-#{$position} { position: $position !important; }
} }
Expand Down
1 change: 1 addition & 0 deletions site/_data/nav.yml
Expand Up @@ -62,6 +62,7 @@
- title: Flex - title: Flex
- title: Float - title: Float
- title: Image replacement - title: Image replacement
- title: Overflow
- title: Position - title: Position
- title: Screenreaders - title: Screenreaders
- title: Shadows - title: Shadows
Expand Down
25 changes: 25 additions & 0 deletions site/docs/4.1/utilities/overflow.md
@@ -0,0 +1,25 @@
---
layout: docs
title: Overflow
description: Use these shorthand utilities for quickly configuring how content overflows an element.
group: utilities
toc: true
---

Barebones `overflow` functionality is provided for two values by default, and they are not responsive.

<div class="bd-example d-md-flex">
<div class="overflow-auto p-3 mb-3 mb-md-0 mr-md-3 bg-light" style="max-width: 260px; max-height: 100px;">
This is an example of using <code>.overflow-auto</code> on an element with set width and height dimensions. By design, this content will vertically scroll.
</div>
<div class="overflow-hidden p-3 bg-light" style="max-width: 260px; max-height: 100px;">
This is an example of using <code>.overflow-hidden</code> on an element with set width and height dimensions.
</div>
</div>

{% highlight html %}
<div class="overflow-auto">...</div>
<div class="overflow-hidden">...</div>
{% endhighlight %}

Using Sass variables, you may customize the overflow utilities by changing the `$overflows` variable in `_variables.scss`.

0 comments on commit 29bd5e3

Please sign in to comment.