diff options
| author | Pierre-Denis Vanduynslager <[email protected]> | 2016-12-28 19:57:38 -0500 |
|---|---|---|
| committer | Pierre-Denis Vanduynslager <[email protected]> | 2016-12-28 19:57:38 -0500 |
| commit | 425d156df27fa6c18e979aa000bfe5a346ee3450 (patch) | |
| tree | 4157dfcbdf8334e9d9fb2bb239f4ae78706bbc71 /docs/utilities | |
| parent | ab2fc63d08b8c53d6f29bcfd73b7f2d5ceaacacd (diff) | |
| parent | e1e621be046a4541a2fd36e445015ee44de3c67e (diff) | |
| download | bootstrap-425d156df27fa6c18e979aa000bfe5a346ee3450.tar.xz bootstrap-425d156df27fa6c18e979aa000bfe5a346ee3450.zip | |
Merge branch 'twbs/v4-dev' into dropdown-keyboard
Diffstat (limited to 'docs/utilities')
| -rw-r--r-- | docs/utilities/borders.md | 46 | ||||
| -rw-r--r-- | docs/utilities/clearfix.md | 36 | ||||
| -rw-r--r-- | docs/utilities/close-icon.md | 13 | ||||
| -rw-r--r-- | docs/utilities/colors.md | 49 | ||||
| -rw-r--r-- | docs/utilities/display-property.md | 29 | ||||
| -rw-r--r-- | docs/utilities/flexbox.md | 523 | ||||
| -rw-r--r-- | docs/utilities/image-replacement.md | 18 | ||||
| -rw-r--r-- | docs/utilities/invisible-content.md | 23 | ||||
| -rw-r--r-- | docs/utilities/responsive-helpers.md | 70 | ||||
| -rw-r--r-- | docs/utilities/screenreaders.md | 23 | ||||
| -rw-r--r-- | docs/utilities/sizing-and-positioning.md | 52 | ||||
| -rw-r--r-- | docs/utilities/spacing.md | 82 | ||||
| -rw-r--r-- | docs/utilities/typography.md | 63 | ||||
| -rw-r--r-- | docs/utilities/vertical-align.md | 37 |
14 files changed, 1064 insertions, 0 deletions
diff --git a/docs/utilities/borders.md b/docs/utilities/borders.md new file mode 100644 index 000000000..1f092c36a --- /dev/null +++ b/docs/utilities/borders.md @@ -0,0 +1,46 @@ +--- +layout: docs +title: Borders +group: utilities +redirect_from: "/utilities/" +--- + +Use border utilities to quickly style the `border` and `border-radius` of an element. Great for images, buttons, or any other element. + +## Border + +Add classes to an element to remove all borders or some borders. + +<div class="bd-example-border-utils"> +{% example html %} +<span class="border-0"></span> +<span class="border-top-0"></span> +<span class="border-right-0"></span> +<span class="border-bottom-0"></span> +<span class="border-left-0"></span> +{% endexample %} +</div> + +## Border-radius + +Add classes to an element to easily round its corners. + +<div class="bd-example bd-example-images"> + <img data-src="holder.js/75x75" class="rounded" alt="Example rounded image"> + <img data-src="holder.js/75x75" class="rounded-top" alt="Example top rounded image"> + <img data-src="holder.js/75x75" class="rounded-right" alt="Example right rounded image"> + <img data-src="holder.js/75x75" class="rounded-bottom" alt="Example bottom rounded image"> + <img data-src="holder.js/75x75" class="rounded-left" alt="Example left rounded image"> + <img data-src="holder.js/75x75" class="rounded-circle" alt="Completely round image"> + <img data-src="holder.js/75x75" class="rounded-0" alt="Example non-rounded image (overrides rounding applied elsewhere)"> +</div> + +{% highlight html %} +<img src="..." alt="..." class="rounded"> +<img src="..." alt="..." class="rounded-top"> +<img src="..." alt="..." class="rounded-right"> +<img src="..." alt="..." class="rounded-bottom"> +<img src="..." alt="..." class="rounded-left"> +<img src="..." alt="..." class="rounded-circle"> +<img src="..." alt="..." class="rounded-0"> +{% endhighlight %} diff --git a/docs/utilities/clearfix.md b/docs/utilities/clearfix.md new file mode 100644 index 000000000..49410df09 --- /dev/null +++ b/docs/utilities/clearfix.md @@ -0,0 +1,36 @@ +--- +layout: docs +title: Clearfix +group: utilities +--- + +Easily clear `float`s by adding `.clearfix` **to the parent element**. Utilizes [the micro clearfix](http://nicolasgallagher.com/micro-clearfix-hack/) as popularized by Nicolas Gallagher. Can also be used as a mixin. + +{% highlight html %} +<div class="clearfix">...</div> +{% endhighlight %} + +{% highlight scss %} +// Mixin itself +@mixin clearfix() { + &::after { + display: block; + content: ""; + clear: both; + } +} + +// Usage as a mixin +.element { + @include clearfix; +} +{% endhighlight %} + +The following example shows how the clearfix can be used. Without the clearfix the wrapping div would not span around the buttons which would cause a broken layout. + +{% example html %} +<div class="bg-info clearfix"> + <button class="btn btn-secondary float-left">Example Button floated left</button> + <button class="btn btn-secondary float-right">Example Button floated right</button> +</div> +{% endexample %} diff --git a/docs/utilities/close-icon.md b/docs/utilities/close-icon.md new file mode 100644 index 000000000..5ec456bcc --- /dev/null +++ b/docs/utilities/close-icon.md @@ -0,0 +1,13 @@ +--- +layout: docs +title: Close icon +group: utilities +--- + +Use a generic close icon for dismissing content like modals and alerts. **Be sure to include text for screen readers**, as we've done with `aria-label`. + +{% example html %} +<button type="button" class="close" aria-label="Close"> + <span aria-hidden="true">×</span> +</button> +{% endexample %} diff --git a/docs/utilities/colors.md b/docs/utilities/colors.md new file mode 100644 index 000000000..f041f6947 --- /dev/null +++ b/docs/utilities/colors.md @@ -0,0 +1,49 @@ +--- +layout: docs +title: Colors +group: utilities +--- + +Convey meaning through color with a handful of emphasis utility classes. These may also be applied to links and will darken on hover just like our default link styles. + +{% example html %} +<p class="text-muted">Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.</p> +<p class="text-primary">Nullam id dolor id nibh ultricies vehicula ut id elit.</p> +<p class="text-success">Duis mollis, est non commodo luctus, nisi erat porttitor ligula.</p> +<p class="text-info">Maecenas sed diam eget risus varius blandit sit amet non magna.</p> +<p class="text-warning">Etiam porta sem malesuada magna mollis euismod.</p> +<p class="text-danger">Donec ullamcorper nulla non metus auctor fringilla.</p> +<p class="text-white">Etiam porta sem malesuada ultricies vehicula.</p> +{% endexample %} + +Contextual text classes also work well on anchors with the provided hover and focus states. **Note that the `.text-white` class has no link styling.** + +{% example html %} +<a href="#" class="text-muted">Muted link</a> +<a href="#" class="text-primary">Primary link</a> +<a href="#" class="text-success">Success link</a> +<a href="#" class="text-info">Info link</a> +<a href="#" class="text-warning">Warning link</a> +<a href="#" class="text-danger">Danger link</a> +{% endexample %} + +Similar to the contextual text color classes, easily set the background of an element to any contextual class. Anchor components will darken on hover, just like the text classes. Background utilities **do not set `color`**, so in some cases you'll want to use `.text-*` utilities. + +{% example html %} +<div class="bg-primary text-white">Nullam id dolor id nibh ultricies vehicula ut id elit.</div> +<div class="bg-success text-white">Duis mollis, est non commodo luctus, nisi erat porttitor ligula.</div> +<div class="bg-info text-white">Maecenas sed diam eget risus varius blandit sit amet non magna.</div> +<div class="bg-warning text-white">Etiam porta sem malesuada magna mollis euismod.</div> +<div class="bg-danger text-white">Donec ullamcorper nulla non metus auctor fringilla.</div> +<div class="bg-inverse text-white">Cras mattis consectetur purus sit amet fermentum.</div> +<div class="bg-faded">Cras mattis consectetur purus sit amet fermentum.</div> +{% endexample %} + +{% callout info %} +#### Dealing with specificity + +Sometimes contextual classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element's content in a `<div>` with the class. +{% endcallout %} + +{% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %} +{{ callout-include | markdownify }} diff --git a/docs/utilities/display-property.md b/docs/utilities/display-property.md new file mode 100644 index 000000000..50ea29367 --- /dev/null +++ b/docs/utilities/display-property.md @@ -0,0 +1,29 @@ +--- +layout: docs +title: Display property +group: utilities +--- + +Use `.d-block`, `.d-inline`, or `.d-inline-block` to simply set an element's [`display` property](https://developer.mozilla.org/en-US/docs/Web/CSS/display) to `block`, `inline`, or `inline-block` (respectively). + +To make an element `display: none`, use our [responsive utilities]({{ site.baseurl }}/layout/responsive-utilities/) instead. + +{% example html %} +<div class="d-inline bg-success">Inline</div> +<div class="d-inline bg-success">Inline</div> +{% endexample %} + +{% example html %} +<span class="d-block bg-primary">Block</span> +{% endexample %} + +{% example html %} +<div class="d-inline-block bg-warning"> + <h3>inline-block</h3> + Boot that strap! +</div> +<div class="d-inline-block bg-warning"> + <h3>inline-block</h3> + Strap that boot! +</div> +{% endexample %} diff --git a/docs/utilities/flexbox.md b/docs/utilities/flexbox.md new file mode 100644 index 000000000..9b6add5c4 --- /dev/null +++ b/docs/utilities/flexbox.md @@ -0,0 +1,523 @@ +--- +layout: docs +title: Flexbox +group: utilities +--- + +Quickly manage the layout, alignment, and sizing of grid columns, navigation, components, and more with a full suite of responsive flexbox utilities. For more complex implementations, custom CSS may be necessary. + +## Contents + +* Will be replaced with the ToC, excluding the "Contents" header +{:toc} + +## Enable flex behaviors + +Apply `display` utilities to create a flexbox container and transform **direct children elements** into flex items. Flex containers and items are able to be modified further with additional flex properties. + +{% example html %} +<div class="d-flex p-2 bd-highlight">I'm a flexbox container!</div> +{% endexample %} + +{% example html %} +<div class="d-inline-flex p-2 bd-highlight">I'm an inline flexbox container!</div> +{% endexample %} + +Responsive variations also exist for `.d-flex` and `.d-inline-flex`. + +{% for bp in site.data.breakpoints %} +- `.d{{ bp.abbr }}-flex` +- `.d{{ bp.abbr }}-inline-flex`{% endfor %} + +## Direction + +Set the direction of flex items in a flex container with direction utilities. In most cases you can omit the horizontal class here as the browser default is `row`. However, you may encounter situations where you needed to explicitly set this value (like responsive layouts). + +Use `.flex-row` to set a horizontal direction (the browser default), or `.flex-row-reverse` to start the horizontal direction from the opposite side. + +{% example html %} +<div class="d-flex flex-row bd-highlight mb-3"> + <div class="p-2 bd-highlight">Flex item 1</div> + <div class="p-2 bd-highlight">Flex item 2</div> + <div class="p-2 bd-highlight">Flex item 3</div> +</div> +<div class="d-flex flex-row-reverse bd-highlight"> + <div class="p-2 bd-highlight">Flex item 1</div> + <div class="p-2 bd-highlight">Flex item 2</div> + <div class="p-2 bd-highlight">Flex item 3</div> +</div> +{% endexample %} + +Use `.flex-column` to set a vertical direction, or `.flex-column-reverse` to start the vertical direction from the opposite side. + +{% example html %} +<div class="d-flex flex-column bd-highlight mb-3"> + <div class="p-2 bd-highlight">Flex item 1</div> + <div class="p-2 bd-highlight">Flex item 2</div> + <div class="p-2 bd-highlight">Flex item 3</div> +</div> +<div class="d-flex flex-column-reverse bd-highlight"> + <div class="p-2 bd-highlight">Flex item 1</div> + <div class="p-2 bd-highlight">Flex item 2</div> + <div class="p-2 bd-highlight">Flex item 3</div> +</div> +{% endexample %} + +Responsive variations also exist for `flex-direction`. + +{% for bp in site.data.breakpoints %} +- `.flex{{ bp.abbr }}-row` +- `.flex{{ bp.abbr }}-row-reverse` +- `.flex{{ bp.abbr }}-column` +- `.flex{{ bp.abbr }}-column-reverse`{% endfor %} + +## Justify content + +Use `justify-content` utilities on flexbox containers to change the alignment of flex items on the main axis (the x-axis to start, y-axis if `flex-direction: column`). Choose from `start` (browser default), `end`, `center`, `between`, or `around`. + +<div class="bd-example"> + <div class="d-flex justify-content-start bd-highlight mb-3"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex justify-content-end bd-highlight mb-3"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex justify-content-center bd-highlight mb-3"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex justify-content-between bd-highlight mb-3"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex justify-content-around bd-highlight"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> + +{% highlight html %} +<div class="d-flex justify-content-start">...</div> +<div class="d-flex justify-content-end">...</div> +<div class="d-flex justify-content-center">...</div> +<div class="d-flex justify-content-between">...</div> +<div class="d-flex justify-content-around">...</div> +{% endhighlight %} + +Responsive variations also exist for `justify-content`. + +{% for bp in site.data.breakpoints %} +- `.justify-content{{ bp.abbr }}-start` +- `.justify-content{{ bp.abbr }}-end` +- `.justify-content{{ bp.abbr }}-center` +- `.justify-content{{ bp.abbr }}-between` +- `.justify-content{{ bp.abbr }}-around`{% endfor %} + +## Align items + +Use `align-items` utilities on flexbox containers to change the alignment of flex items on the cross axis (the y-axis to start, x-axis if `flex-direction: column`). Choose from `start`, `end`, `center`, `baseline`, or `stretch` (browser default). + +<div class="bd-example"> + <div class="d-flex align-items-start bd-highlight mb-3" style="height: 100px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex align-items-end bd-highlight mb-3" style="height: 100px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex align-items-center bd-highlight mb-3" style="height: 100px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex align-items-baseline bd-highlight mb-3" style="height: 100px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex align-items-stretch bd-highlight" style="height: 100px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> + +{% highlight html %} +<div class="d-flex align-items-start">...</div> +<div class="d-flex align-items-end">...</div> +<div class="d-flex align-items-center">...</div> +<div class="d-flex align-items-baseline">...</div> +<div class="d-flex align-items-stretch">...</div> +{% endhighlight %} + +Responsive variations also exist for `align-items`. + +{% for bp in site.data.breakpoints %} +- `.align-items{{ bp.abbr }}-start` +- `.align-items{{ bp.abbr }}-end` +- `.align-items{{ bp.abbr }}-center` +- `.align-items{{ bp.abbr }}-baseline` +- `.align-items{{ bp.abbr }}-stretch`{% endfor %} + +## Align self + +Use `align-self` utilities on flexbox items to individually change their alignment on the cross axis (the y-axis to start, x-axis if `flex-direction: column`). Choose from the same options as `align-items`: `start`, `end`, `center`, `baseline`, or `stretch` (browser default). + +<div class="bd-example"> + <div class="d-flex bd-highlight mb-3" style="height: 100px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="align-self-start p-2 bd-highlight">Aligned flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex bd-highlight mb-3" style="height: 100px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="align-self-end p-2 bd-highlight">Aligned flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex bd-highlight mb-3" style="height: 100px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="align-self-center p-2 bd-highlight">Aligned flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex bd-highlight mb-3" style="height: 100px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="align-self-baseline p-2 bd-highlight">Aligned flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> + <div class="d-flex bd-highlight" style="height: 100px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="align-self-stretch p-2 bd-highlight">Aligned flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> + +{% highlight html %} +<div class="align-self-start">Aligned flex item</div> +<div class="align-self-end">Aligned flex item</div> +<div class="align-self-center">Aligned flex item</div> +<div class="align-self-baseline">Aligned flex item</div> +<div class="align-self-stretch">Aligned flex item</div> +{% endhighlight %} + +Responsive variations also exist for `align-self`. + +{% for bp in site.data.breakpoints %} +- `.align-self{{ bp.abbr }}-start` +- `.align-self{{ bp.abbr }}-end` +- `.align-self{{ bp.abbr }}-center` +- `.align-self{{ bp.abbr }}-baseline` +- `.align-self{{ bp.abbr }}-stretch`{% endfor %} + +## Auto margins + +Flexbox can do some pretty awesome things when you mix flex alignments with auto margins. + +### With justify-content + +Easily move all flex items to one side, but keep another on the opposite end by mixing `justify-content` with `margin-right: auto` or `margin-left: auto`. + +{% example html %} +<div class="d-flex justify-content-end bd-highlight mb-3"> + <div class="mr-auto p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> +</div> + +<div class="d-flex justify-content-start bd-highlight"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="ml-auto p-2 bd-highlight">Flex item</div> +</div> +{% endexample %} + +### With align-items + +Similarly, move one flex item to the top or bottom of a container by mixing `align-items`, `flex-direction: column`, and `margin-top: auto` or `margin-bottom: auto`. + +{% example html %} +<div class="d-flex align-items-start flex-column bd-highlight mb-3" style="height: 200px;"> + <div class="mb-auto p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> +</div> + +<div class="d-flex align-items-end flex-column bd-highlight mb-3" style="height: 200px;"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="mt-auto p-2 bd-highlight">Flex item</div> +</div> +{% endexample %} + +## Wrap + +Change how flex items wrap in a flex container. Choose from no wrapping at all (the browser default) with `.flex-nowrap`, wrapping with `.flex-wrap`, or reverse wrapping with `.flex-wrap-reverse`. + +<div class="bd-example"> + <div class="d-flex flex-nowrap bd-highlight"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> +{% highlight html %} +<div class="d-flex flex-nowrap"> + ... +</div> +{% endhighlight %} + +<div class="bd-example"> + <div class="d-flex flex-wrap bd-highlight"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> +{% highlight html %} +<div class="d-flex flex-wrap"> + ... +</div> +{% endhighlight %} + +<div class="bd-example"> + <div class="d-flex flex-wrap-reverse bd-highlight"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> +{% highlight html %} +<div class="d-flex flex-wrap-reverse"> + ... +</div> +{% endhighlight %} + + +{% example html %} +{% endexample %} + +Responsive variations also exist for `flex-wrap`. + +{% for bp in site.data.breakpoints %} +- `.flex{{ bp.abbr }}-nowrap` +- `.flex{{ bp.abbr }}-wrap` +- `.flex{{ bp.abbr }}-wrap-reverse`{% endfor %} + +## Order + +Change the _visual_ order of specific flex items with a handful of `order` utilities. We only provide options for making an item first or last, as well as a reset to use the DOM order. As `order` takes any integer value (e.g., `5`), add custom CSS for any additional values needed. + +{% example html %} +<div class="d-flex flex-nowrap bd-highlight"> + <div class="flex-last p-2 bd-highlight">First flex item</div> + <div class="p-2 bd-highlight">Second flex item</div> + <div class="flex-first p-2 bd-highlight">Third flex item</div> +</div> +{% endexample %} + +Responsive variations also exist for `order`. + +{% for bp in site.data.breakpoints %} +- `.order{{ bp.abbr }}-first` +- `.order{{ bp.abbr }}-last` +- `.order{{ bp.abbr }}-unordered`{% endfor %} + +## Align content + +Use `align-content` utilities on flexbox containers to align flex items *together* on the cross axis. Choose from `start` (browser default), `end`, `center`, `between`, `around`, or `stretch`. To demonstrate these utilities, we've enforced `flex-wrap: wrap` and increased the number of flex items. + +**Heads up!** This property has no affect on single rows of flex items. + +<div class="bd-example"> + <div class="d-flex align-content-start flex-wrap bd-highlight mb-3" style="height: 200px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> +{% highlight html %} +<div class="d-flex align-content-start flex-wrap"> + ... +</div> +{% endhighlight %} + +<div class="bd-example"> + <div class="d-flex align-content-end flex-wrap bd-highlight mb-3" style="height: 200px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> +{% highlight html %} +<div class="d-flex align-content-end flex-wrap">...</div> +{% endhighlight %} + +<div class="bd-example"> + <div class="d-flex align-content-center flex-wrap bd-highlight mb-3" style="height: 200px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> +{% highlight html %} +<div class="d-flex align-content-center flex-wrap">...</div> +{% endhighlight %} + +<div class="bd-example"> + <div class="d-flex align-content-between flex-wrap bd-highlight mb-3" style="height: 200px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> +{% highlight html %} +<div class="d-flex align-content-between flex-wrap">...</div> +{% endhighlight %} + +<div class="bd-example"> + <div class="d-flex align-content-around flex-wrap bd-highlight mb-3" style="height: 200px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> +{% highlight html %} +<div class="d-flex align-content-around flex-wrap">...</div> +{% endhighlight %} + +<div class="bd-example"> + <div class="d-flex align-content-stretch flex-wrap bd-highlight mb-3" style="height: 200px"> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + <div class="p-2 bd-highlight">Flex item</div> + </div> +</div> +{% highlight html %} +<div class="d-flex align-content-stretch flex-wrap">...</div> +{% endhighlight %} + +Responsive variations also exist for `align-content`. + +{% for bp in site.data.breakpoints %} +- `.align-content{{ bp.abbr }}-start` +- `.align-content{{ bp.abbr }}-end` +- `.align-content{{ bp.abbr }}-center` +- `.align-content{{ bp.abbr }}-around` +- `.align-content{{ bp.abbr }}-stretch`{% endfor %} diff --git a/docs/utilities/image-replacement.md b/docs/utilities/image-replacement.md new file mode 100644 index 000000000..720e7b5a9 --- /dev/null +++ b/docs/utilities/image-replacement.md @@ -0,0 +1,18 @@ +--- +layout: docs +title: Image replacement +group: utilities +--- + +Utilize the `.text-hide` class or mixin to help replace an element's text content with a background image. + +{% highlight html %} +<h1 class="text-hide">Custom heading</h1> +{% endhighlight %} + +{% highlight scss %} +// Usage as a mixin +.heading { + @include text-hide; +} +{% endhighlight %} diff --git a/docs/utilities/invisible-content.md b/docs/utilities/invisible-content.md new file mode 100644 index 000000000..84da6ad01 --- /dev/null +++ b/docs/utilities/invisible-content.md @@ -0,0 +1,23 @@ +--- +layout: docs +title: Invisible content +group: utilities +--- + +The `.invisible` class can be used to toggle only the visibility of an element, meaning its `display` is not modified and the element can still affect the flow of the document. + +{% highlight html %} +<div class="invisible">...</div> +{% endhighlight %} + +{% highlight scss %} +// Class +.invisible { + visibility: hidden; +} + +// Usage as a mixin +.element { + @include invisible; +} +{% endhighlight %} diff --git a/docs/utilities/responsive-helpers.md b/docs/utilities/responsive-helpers.md new file mode 100644 index 000000000..35e7fcf2f --- /dev/null +++ b/docs/utilities/responsive-helpers.md @@ -0,0 +1,70 @@ +--- +layout: docs +title: Responsive helpers +group: utilities +--- + +## Responsive embeds + +Allow browsers to determine video or slideshow dimensions based on the width of their containing block by creating an intrinsic ratio that will properly scale on any device. + +Rules are directly applied to `<iframe>`, `<embed>`, `<video>`, and `<object>` elements; optionally use an explicit descendant class `.embed-responsive-item` when you want to match the styling for other attributes. + +**Pro-Tip!** You don't need to include `frameborder="0"` in your `<iframe>`s as we override that for you. + +{% example html %} +<div class="embed-responsive embed-responsive-16by9"> + <iframe class="embed-responsive-item" src="//www.youtube.com/embed/zpOULjyy-n8?rel=0" allowfullscreen></iframe> +</div> +{% endexample %} + +Aspect ratios can be customized with modifier classes. + +{% highlight html %} +<!-- 21:9 aspect ratio --> +<div class="embed-responsive embed-responsive-21by9"> + <iframe class="embed-responsive-item" src="..."></iframe> +</div> + +<!-- 16:9 aspect ratio --> +<div class="embed-responsive embed-responsive-16by9"> + <iframe class="embed-responsive-item" src="..."></iframe> +</div> + +<!-- 4:3 aspect ratio --> +<div class="embed-responsive embed-responsive-4by3"> + <iframe class="embed-responsive-item" src="..."></iframe> +</div> + +<!-- 1:1 aspect ratio --> +<div class="embed-responsive embed-responsive-1by1"> + <iframe class="embed-responsive-item" src="..."></iframe> +</div> +{% endhighlight %} + +## Responsive floats + +These utility classes float an element to the left or right, or disable floating, based on the current viewport size using the [CSS `float` property](https://developer.mozilla.org/en-US/docs/Web/CSS/float). `!important` is included to avoid specificity issues. These use the same viewport width breakpoints as the grid system. + +Two similar non-responsive Sass mixins (`float-left` and `float-right`) are also available. + +{% example html %} +<div class="float-left">Float left on all viewport sizes</div><br> +<div class="float-right">Float right on all viewport sizes</div><br> +<div class="float-none">Don't float on all viewport sizes</div><br> + +<div class="float-sm-left">Float left on viewports sized SM (small) or wider</div><br> +<div class="float-md-left">Float left on viewports sized MD (medium) or wider</div><br> +<div class="float-lg-left">Float left on viewports sized LG (large) or wider</div><br> +<div class="float-xl-left">Float left on viewports sized XL (extra-large) or wider</div><br> +{% endexample %} + +{% highlight scss %} +// Related simple non-responsive mixins +.element { + @include float-left; +} +.another-element { + @include float-right; +} +{% endhighlight %} diff --git a/docs/utilities/screenreaders.md b/docs/utilities/screenreaders.md new file mode 100644 index 000000000..411f3ddb2 --- /dev/null +++ b/docs/utilities/screenreaders.md @@ -0,0 +1,23 @@ +--- +layout: docs +title: Screenreaders +group: utilities +--- + +Hide an element to all devices **except screen readers** with `.sr-only`. Combine `.sr-only` with `.sr-only-focusable` to show the element again when it's focused (e.g. by a keyboard-only user). Can also be used as mixins. + +{% comment %} +Necessary for following [accessibility best practices]({{ site.baseurl }}/getting-started/#accessibility). +{% endcomment %} + +{% highlight html %} +<a class="sr-only sr-only-focusable" href="#content">Skip to main content</a> +{% endhighlight %} + +{% highlight scss %} +// Usage as a mixin +.skip-navigation { + @include sr-only; + @include sr-only-focusable; +} +{% endhighlight %} diff --git a/docs/utilities/sizing-and-positioning.md b/docs/utilities/sizing-and-positioning.md new file mode 100644 index 000000000..a6de778ca --- /dev/null +++ b/docs/utilities/sizing-and-positioning.md @@ -0,0 +1,52 @@ +--- +layout: docs +title: Sizing and positioning +group: utilities +--- + +## Fixed positioning + +The `.pos-f-t` class can be used to easily position elements at the top of the viewport and make them as wide as the viewport. **Be sure you understand the ramifications of fixed-position elements within your project.** Here's how the class is defined: + +{% highlight scss %} +.pos-f-t { + position: fixed; + top: 0; + right: 0; + left: 0; + z-index: $zindex-navbar-fixed; +} +{% endhighlight %} + + +## Width and height + +Easily make an element as wide or as tall (relative to its parent) with our width and height utilities. Includes support for `25%`, `50%`, `75%`, and `100%`. + +{% example html %} +<div class="w-25 p-3" style="background-color: #eee;">Width 25%</div> +<div class="w-50 p-3" style="background-color: #eee;">Width 50%</div> +<div class="w-75 p-3" style="background-color: #eee;">Width 75%</div> +<div class="w-100 p-3" style="background-color: #eee;">Width 100%</div> +{% endexample %} + +{% example html %} +<div style="height: 100px; background-color: rgba(255,0,0,0.1);"> + <div class="h-25 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 25%</div> + <div class="h-50 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 50%</div> + <div class="h-75 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 75%</div> + <div class="h-100 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 100%</div> +</div> +{% endexample %} + +You can also use `max-width: 100%;` and `max-height: 100%;` utilities as needed. + +{% example html %} +<img class="mw-100" data-src="holder.js/1000px100?text=Max-width%20%3D%20100%25" alt="Max-width 100%"> +{% endexample %} + +{% example html %} +<div style="height: 100px; background-color: rgba(255,0,0,0.1);"> + <div class="mh-100" style="width: 100px; height: 200px; background-color: rgba(0,0,255,0.1);">Max-height 100%</div> +</div> +{% endexample %} diff --git a/docs/utilities/spacing.md b/docs/utilities/spacing.md new file mode 100644 index 000000000..0a5132941 --- /dev/null +++ b/docs/utilities/spacing.md @@ -0,0 +1,82 @@ +--- +layout: docs +title: Spacing +group: utilities +--- + +Assign responsive-friendly `margin` or `padding` values to an element or a subset of its sides with shorthand classes. Includes support for individual properties, all properties, and vertical and horizontal properties. Classes are built from a default Sass map ranging from `.25rem` to `3rem`. + +## Contents + +* Will be replaced with the ToC, excluding the "Contents" header +{:toc} + +## Notation + +Spacing utilities that apply to all breakpoints, from `xs` to `xl`, have no breakpoint abbreviation in them. This is because those classes are applied from `min-width: 0` and up, and thus are not bound by a media query. The remaining breakpoints, however, do include a breakpoint abbreviation. + +The classes are named using the format `{property}{sides}-{size}` for `xs` and `{property}{sides}-{breakpoint}-{size}` for `sm`, `md`, `lg`, and `xl`. + +Where *property* is one of: + +* `m` - for classes that set `margin` +* `p` - for classes that set `padding` + +Where *sides* is one of: + +* `t` - for classes that set `margin-top` or `padding-top` +* `b` - for classes that set `margin-bottom` or `padding-bottom` +* `l` - for classes that set `margin-left` or `padding-left` +* `r` - for classes that set `margin-right` or `padding-right` +* `x` - for classes that set both `*-left` and `*-right` +* `y` - for classes that set both `*-top` and `*-bottom` +* blank - for classes that set a `margin` or `padding` on all 4 sides of the element + +Where *size* is one of: + +* `0` - for classes that eliminate the `margin` or `padding` by setting it to `0` +* `1` - (by default) for classes that set the `margin` or `padding` to `$spacer-x * .25` or `$spacer-y * .25` +* `2` - (by default) for classes that set the `margin` or `padding` to `$spacer-x * .5` or `$spacer-y * .5` +* `3` - (by default) for classes that set the `margin` or `padding` to `$spacer-x` or `$spacer-y` +* `4` - (by default) for classes that set the `margin` or `padding` to `$spacer-x * 1.5` or `$spacer-y * 1.5` +* `5` - (by default) for classes that set the `margin` or `padding` to `$spacer-x * 3` or `$spacer-y * 3` + +(You can add more sizes by adding entries to the `$spacers` Sass map variable.) + +## Examples + +Here are some representative examples of these classes: + +{% highlight scss %} +.mt-0 { + margin-top: 0 !important; +} + +.ml-1 { + margin-left: ($spacer-x * .25) !important; +} + +.px-2 { + padding-left: ($spacer-x * .5) !important; + padding-right: ($spacer-x * .5) !important; +} + +.p-3 { + padding: $spacer-y $spacer-x !important; +} +{% endhighlight %} + +### Horizontal centering +Additionally, Bootstrap also includes an `.mx-auto` class for horizontally centering fixed-width block level content—that is, content that has `display: block` and a `width` set—by setting the horizontal margins to `auto`. + +<div class="bd-example"> + <div class="mx-auto" style="width: 200px; background-color: rgba(86,61,124,.15);"> + Centered element + </div> +</div> + +{% highlight html %} +<div class="mx-auto" style="width: 200px;"> + Centered element +</div> +{% endhighlight %} diff --git a/docs/utilities/typography.md b/docs/utilities/typography.md new file mode 100644 index 000000000..42b61131e --- /dev/null +++ b/docs/utilities/typography.md @@ -0,0 +1,63 @@ +--- +layout: docs +title: Typography +group: utilities +--- + +The following utilities can be used to add additional styles to texts. + +## Contents + +* Will be replaced with the ToC, excluding the "Contents" header +{:toc} + +## Text alignment + +Easily realign text to components with text alignment classes. + +{% example html %} +<p class="text-justify">Ambitioni dedisse scripsisse iudicaretur. Cras mattis iudicium purus sit amet fermentum. Donec sed odio operae, eu vulputate felis rhoncus. Praeterea iter est quasdam res quas ex communi. At nos hinc posthac, sitientis piros Afros. Petierunt uti sibi concilium totius Galliae in diem certam indicere. Cras mattis iudicium purus sit amet fermentum.</p> +{% endexample %} + +{% example html %} +<div class="card"> + <div class="card-block text-nowrap"> + Curabitur blandit tempus ardua ridiculus sed magna. + </div> +</div> +{% endexample %} + +For left, right, and center alignment, responsive classes are available that use the same viewport width breakpoints as the grid system. + +{% example html %} +<p class="text-left">Left aligned text on all viewport sizes.</p> +<p class="text-center">Center aligned text on all viewport sizes.</p> +<p class="text-right">Right aligned text on all viewport sizes.</p> + +<p class="text-sm-left">Left aligned text on viewports sized SM (small) or wider.</p> +<p class="text-md-left">Left aligned text on viewports sized MD (medium) or wider.</p> +<p class="text-lg-left">Left aligned text on viewports sized LG (large) or wider.</p> +<p class="text-xl-left">Left aligned text on viewports sized XL (extra-large) or wider.</p> +{% endexample %} + +## Text transform + +Transform text in components with text capitalization classes. + +{% example html %} +<p class="text-lowercase">Lowercased text.</p> +<p class="text-uppercase">Uppercased text.</p> +<p class="text-capitalize">CapiTaliZed text.</p> +{% endexample %} + +Note how `text-capitalize` only changes the first letter of each word, leaving the case of any other letters unaffected. + +## Font weight and italics + +Quickly change the weight (boldness) of text or italicize text. + +{% example html %} +<p class="font-weight-bold">Bold text.</p> +<p class="font-weight-normal">Normal weight text.</p> +<p class="font-italic">Italic text.</p> +{% endexample %} diff --git a/docs/utilities/vertical-align.md b/docs/utilities/vertical-align.md new file mode 100644 index 000000000..09ae115b0 --- /dev/null +++ b/docs/utilities/vertical-align.md @@ -0,0 +1,37 @@ +--- +layout: docs +title: Vertical alignment +group: utilities +--- + +Change the alignment of elements with the [`vertical-alignment`](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align) utilities. Please note that vertical-align only affects inline, inline-block, inline-table, and table cell elements. + +Choose from `.align-baseline`, `.align-top`, `.align-middle`, `.align-bottom`, `.align-text-bottom`, and `.align-text-top` as needed. + +With inline elements: + +{% example html %} +<span class="align-baseline">baseline</span> +<span class="align-top">top</span> +<span class="align-middle">middle</span> +<span class="align-bottom">bottom</span> +<span class="align-text-top">text-top</span> +<span class="align-text-bottom">text-bottom</span> +{% endexample %} + +With table cells: + +{% example html %} +<table style="height: 100px;"> + <tbody> + <tr> + <td class="align-baseline">baseline</td> + <td class="align-top">top</td> + <td class="align-middle">middle</td> + <td class="align-bottom">bottom</td> + <td class="align-text-top">text-top</td> + <td class="align-text-bottom">text-bottom</td> + </tr> + </tbody> +</table> +{% endexample %} |
