# Object fit

> Utilities for controlling how an image or video is resized to fit its container.

Source: https://www.zenplates.co/documentation/utilities/object-fit/ (Utilities › Layout)

| Class             | Properties             |
| ----------------- | ---------------------- |
| `.object-contain` | `object-fit: contain;` |
| `.object-cover`   | `object-fit: cover;`   |
| `.object-fill`    | `object-fit: fill;`    |
| `.object-none`    | `object-fit: none;`    |

## Usage

Use `.object-{fit}` with an `<img>` or `<video>` element that has a set width and height to control how its content fills that space.

Use `.object-cover` to fill the space, cropping the image if its proportions are different, and `.object-contain` to fit the whole image within the space, leaving empty space around it if needed. `.object-fill` stretches the image to fill the space, and `.object-none` shows the image at its original size, centered and cropped.

```html
<img class="object-cover w-full" style="height: 120px;" src="..." alt="...">
<img class="object-contain w-full" style="height: 120px;" src="..." alt="...">
<img class="object-fill w-full" style="height: 120px;" src="..." alt="...">
<img class="object-none w-full" style="height: 120px;" src="..." alt="...">
```

## Variants

By default, only responsive variants are generated for object fit utilities.

### Responsive

To control how an image fits its container at a specific breakpoint, add a `{screen}:` prefix to any existing object fit utility.

For example, use `.md:object-cover` to apply the `object-cover` utility at only medium screen sizes and above.

### Hover-state

To include hover-state variants like `.hover:object-cover`, add `"object-fit"` to the `$hover-variants` variable when [recompiling your CSS](https://www.zenplates.co/documentation/customization/using-sass-source-files):

```scss
$hover-variants: (
  // ...
  "object-fit",
);
```
