/* 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;
}
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 :: input type color |
Css :: css styles responsive password input eye |
Css :: profile page html css template |
Css :: jpa select date format |
Css :: count how many characters in the same position are eqial in both strings |
Css :: css hover pointer |
Css :: flexbox in css |
Css :: Responsive Web Design - Frameworks |
Css :: materialize css icons |
Css :: popsition relative css |
Css :: css active button |
Css :: css block |
Css :: chrome developer tools css customize |
Css :: adminlte.min.css.map error |
Css :: css loop |
Css :: set another font in css |
Css :: crop image in img |
Css :: how change the text position |
Css :: * css meaning |
Css :: background |
Css :: html display text in alternating coloured panels |
Css :: gmail auto rewize dont |
Css :: css horror fonts |
Css :: span flex height |
Css :: centering icons in footer |
Css :: javascript typewriter effect left to right |
Css :: How to run our spider |
Css :: mac menu bar height |
Css :: sass rainbow color background |
Css :: 0 |