/* Valeurs avec un mot-clé */
object-fit: fill;
object-fit: contain;
object-fit: cover;
object-fit: none;
object-fit: scale-down;
/* Valeurs globales */
object-fit: inherit;
object-fit: initial;
object-fit: unset;
img {
width: 200px;
height:
400px;
object-fit: cover;
}
img{
object-fit: cover|contain|fill|none|scale-down;
}
object-fit: fill;
object-fit: contain;
object-fit: none;
object-fit: scale-down;
img {
width: 200px;
height:
400px;
object-fit: cover;
}
The object-fit CSS property sets how the content of a replaced element, such as an <img> or <video>, should be resized to fit its container.
img {
width: 200px;
height: 300px;
object-fit: cover;
}
/*image cover*/
object-fit: cover;
/*image perfect size css html*/
background image to fit inside container which maintaining dimensions.
<section>
<h2>object-fit: fill</h2>
<img class="fill" src="mdn_logo_only_color.png" alt="MDN Logo">
<img class="fill narrow" src="mdn_logo_only_color.png" alt="MDN Logo">
<h2>object-fit: contain</h2>
<img class="contain" src="mdn_logo_only_color.png" alt="MDN Logo">
<img class="contain narrow" src="mdn_logo_only_color.png" alt="MDN Logo">
<h2>object-fit: cover</h2>
<img class="cover" src="mdn_logo_only_color.png" alt="MDN Logo">
<img class="cover narrow" src="mdn_logo_only_color.png" alt="MDN Logo">
<h2>object-fit: none</h2>
<img class="none" src="mdn_logo_only_color.png" alt="MDN Logo">
<img class="none narrow" src="mdn_logo_only_color.png" alt="MDN Logo">
<h2>object-fit: scale-down</h2>
<img class="scale-down" src="mdn_logo_only_color.png" alt="MDN Logo">
<img class="scale-down narrow" src="mdn_logo_only_color.png" alt="MDN Logo">
</section>
/* The object-fit CSS property sets how the content of a replaced
element, such as an <img> or <video>,
should be resized to fit its container.
The position of the replaced element can be affected using CSS,
but not the contents of the replaced element itself.
Some replaced elements, such as <iframe> elements,
may have stylesheets of their own, but they don't inherit the styles
of the parent document. */
/* Global */
object-fit: inherit;
object-fit: initial;
object-fit: revert;
object-fit: unset;
/* VALUES */
object-fit: contain;
/*
The replaced content is scaled to maintain its aspect ratio while fitting
within the element’s content box. The entire object is made to fill the
box, while preserving its aspect ratio, so the object will be
"letterboxed" if its aspect ratio does not match the aspect ratio
of the box.
*/
object-fit: cover;
/*
The replaced content is sized to maintain its aspect ratio
while filling the element’s entire content box.
If the object's aspect ratio does not match the aspect ratio of its box,
then the object will be clipped to fit.
*/
object-fit: fill;
/*
The replaced content is sized to fill the element’s content box.
The entire object will completely fill the box.
If the object's aspect ratio does not match the aspect ratio of its box,
then the object will be stretched to fit.
*/
object-fit: none;
/*
The replaced content is not resized.
*/
object-fit: scale-down;
/*
The content is sized as if none or contain were specified,
whichever would result in a smaller concrete object size.
*/
Code Example |
---|
Css :: add expanding underline on page load css |
Css :: red asterix css |
Css :: create arrow div css |
Css :: css cut lines |
Css :: Apply image as full screen responsive background |
Css :: css text overflow |
Css :: responsive width css |
Css :: remove or hide powered by text from Google Translate |
Css :: Add border to text - Css |
Css :: css break after 2 words |
Css :: change bg color on hover |
Css :: on hover disabled cursor |
Css :: add textcontent on hover |
Css :: css hide scrollbar but scrollable |
Css :: scss maps´ |
Css :: css to increase font size |
Css :: how to create wave like border |
Css :: css background gradient |
Css :: css hover |
Css :: css responsive image |
Css :: constraint barrier example |
Css :: css scale |
Css :: custom select dropdown css only codepen |
Css :: ellipsis |
Css :: last child of last child tailwind |
Css :: padding block |
Css :: flex items not taking full width |
Css :: font color css |
Css :: tampermonkey custom css |
Css :: function for style your theme wordpress php |