CSS Live Demo: object-fit Click the demo button below!
selector {
    object-fit: fill | contain | cover | none | scale-down;
}
<div class="container">
    <img src="flower.jpg" alt="flower">
</div>
.container {
    width: 300px;
    height: 100px;
    border: 5px dashed red;
}
img {
    width: 100%;
    height: 100%;
    object-fit: fill;
}
Live Example Preview
<div class="container">
    <video src="flower.webm" autoplay muted playsinline loop></video>
</div>
.container {
    width: 300px;
    height: 100px;
    border: 5px dashed red;
}
video {
    width: 100%;
    height: 100%;
    object-fit: fill;
}
Live Example Preview
<div class="container">
    <img src="flower.jpg" alt="flower">
</div>
.container {
    width: 300px;
    height: 100px;
    border: 5px dashed red;
}
img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
Live Example Preview
<div class="container">
    <video src="flower.webm" autoplay muted playsinline loop></video>
</div>
.container {
    width: 300px;
    height: 100px;
    border: 5px dashed red;
}
video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
Live Example Preview
<div class="container">
    <img src="flower.jpg" alt="flower">
</div>
.container {
    width: 300px;
    height: 100px;
    border: 5px dashed red;
}
img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
Live Example Preview
<div class="container">
    <video src="flower.webm" autoplay muted playsinline loop></video>
</div>
.container {
    width: 300px;
    height: 100px;
    border: 5px dashed red;
}
video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
Live Example Preview
<div class="container">
    <img src="flower.jpg" alt="flower">
</div>
.container {
    width: 300px;
    height: 100px;
    border: 5px dashed red;
}
img {
    width: 100%;
    height: 100%;
    object-fit: none;
}
Live Example Preview
<div class="container">
    <video src="flower.webm" autoplay muted playsinline loop></video>
</div>
.container {
    width: 300px;
    height: 100px;
    border: 5px dashed red;
}
video {
    width: 100%;
    height: 100%;
    object-fit: none;
}
Live Example Preview
<div class="container">
    <img src="flower.jpg" alt="flower">
</div>
.container {
    width: 300px;
    height: 100px;
    border: 5px dashed red;
}
img {
    width: 100%;
    height: 100%;
    object-fit: scale-down;
}
Live Example Preview
<div class="container">
    <video src="flower.webm" autoplay muted playsinline loop></video>
</div>
.container {
    width: 300px;
    height: 100px;
    border: 5px dashed red;
}
video {
    width: 100%;
    height: 100%;
    object-fit: scale-down;
}
Live Example Preview