-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Utilities for overflow and object fit (#36848)
* Added "overflow-x" and "overflow-y" - Having the same properties as overflow but for just the x and y axises - Usecase being I want my y axis to be scrollable but not my x axis - E.g a card with a vertical list of items. * Added "object-fit" utilities - The CSS object-fit property is used to specify how an <img> or <video> should be resized to fit its container. - A responsive alternative to using background-img for a resizable fill/fit image. * Updated documantation for the overflow utilities - Now includes docs for `overflow-x` and `overflow-y` utilities * Placeholder shortcode updated - Can now choose to render an img tag or svg - The image contains a base64 svg generated within the template - example shortcode updated to detect, replace and render preview of 'img' tags as well * New documentaion for Object Fit added - Documentation added for the 'object-fit' util * Updated spell checks issues * Update object-fit.md * Update overflow.md * Update object-fit.md * Updated markup to address HTML Validation Errors - error: Bad value for attribute "src" on element "img": Illegal character in scheme data: space is not allowed. - info warning: Self-closing tag syntax in text/html documents is widely discouraged; it's unnecessary and interacts badly with other HTML features (e.g., unquoted attribute values). If you're using a tool that injects self-closing tag syntax into all void elements, without any option to prevent it from doing so, then consider switching to a different tool. * Updated Fix - Added Legibility to the img markup (example.html) - Fixed issue with example not working properly (because image closing tag no longer has "/>" ) * update values by step of 0.25 in bundlewatch.config The following values in .bundlewatch.config.json have been updated: - ./dist/css/bootstrap-utilities.css - ./dist/css/bootstrap-utilities.min.css - ./dist/css/bootstrap.css - ./dist/css/bootstrap.min.css Co-authored-by: Daniel O <[email protected]> Co-authored-by: Mark Otto <[email protected]>
- Loading branch information
1 parent
4822984
commit 708a3a0
Showing
7 changed files
with
168 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
layout: docs | ||
title: Object fit | ||
description: Use the object fit utilities to modify how the content of a [replaced element](https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element), such as an `<img>` or `<video>`, should be resized to fit its container. | ||
group: utilities | ||
toc: true | ||
--- | ||
|
||
## How it works | ||
|
||
Change the value of the [`object-fit` property](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) with our responsive `object-fit` utility classes. This property tells the content to fill the parent container in a variety of ways, such as preserving the aspect ratio or stretching to take up as much space as possible. | ||
|
||
Classes for the value of `object-fit` are named using the format `.object-fit-{value}`. Choose from the following values: | ||
|
||
- `contain` | ||
- `cover` | ||
- `fill` | ||
- `scale` (for scale-down) | ||
- `none` | ||
|
||
## Examples | ||
|
||
Add the `object-fit-{value}` class to the [replaced element](https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element): | ||
|
||
{{< example class="d-flex overflow-auto" >}} | ||
{{< placeholder width="140" height="120" class="object-fit-contain border rounded" text="Object fit contain" markup="img" >}} | ||
{{< placeholder width="140" height="120" class="object-fit-cover border rounded" text="Object fit cover" markup="img" >}} | ||
{{< placeholder width="140" height="120" class="object-fit-fill border rounded" text="Object fit fill" markup="img" >}} | ||
{{< placeholder width="140" height="120" class="object-fit-scale border rounded" text="Object fit scale down" markup="img" >}} | ||
{{< placeholder width="140" height="120" class="object-fit-none border rounded" text="Object fit none" markup="img" >}} | ||
{{< /example >}} | ||
|
||
## Responsive | ||
|
||
Responsive variations also exist for each `object-fit` value using the format `.object-fit-{breakpoint}-{value}`, for the following breakpoint abbreviations: `sm`, `md`, `lg`, `xl`, and `xxl`. Classes can be combined for various effects as you need. | ||
|
||
{{< example class="d-flex overflow-auto" >}} | ||
{{< placeholder width="140" height="80" class="object-fit-sm-contain border rounded" text="Contain on sm" markup="img" >}} | ||
{{< placeholder width="140" height="80" class="object-fit-md-contain border rounded" text="Contain on md" markup="img" >}} | ||
{{< placeholder width="140" height="80" class="object-fit-lg-contain border rounded" text="Contain on lg" markup="img" >}} | ||
{{< placeholder width="140" height="80" class="object-fit-xl-contain border rounded" text="Contain on xl" markup="img" >}} | ||
{{< placeholder width="140" height="80" class="object-fit-xxl-contain border rounded" text="Contain on xxl" markup="img" >}} | ||
{{< /example >}} | ||
|
||
## Video | ||
|
||
The `.object-fit-{value}` and responsive `.object-fit-{breakpoint}-{value}` utilities also work on `<video>` elements. | ||
|
||
```html | ||
<video src="..." class="object-fit-contain" autoplay></video> | ||
<video src="..." class="object-fit-cover" autoplay></video> | ||
<video src="..." class="object-fit-fill" autoplay></video> | ||
<video src="..." class="object-fit-scale" autoplay></video> | ||
<video src="..." class="object-fit-none" autoplay></video> | ||
``` | ||
|
||
## Utilities API | ||
|
||
Object fit utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}}) | ||
|
||
{{< scss-docs name="utils-object-fit" file="scss/_utilities.scss" >}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters