This fixes an issue where the fluid videos are not really fluid. While the visible video scales down, the video box, remains static height, e.g 60px, causing lots of white space above/below mp4
If this does not bother you, feel free to skip all this, but it is recommended to get a correct display, especially for the mp4 banners
We cant simply use height: auto; because videos have a default height of 150px, causing really bad layout shifts (
bad seo for 2021 )
So, lets get to the magic, what does this css do? In short,
- It ensures cross browser compability, by reverting to the old behavour if custom css properties are not supposted ( cough, IE )
- toplist owner mistakes by applying wrong html markup
- Not adding more dom deepth like older variable aspect ratio boxes ( 2 less child nodes for each banner to be exact )
- object-fit: fill; This is pureley for people using lazy load libraries with placeholder images which are smaller than a member banner, thus stretching the placeholder. And since videos default behavour is to contain possible poster/placeholder this makes sure it has same dimension as the video itself
Open your css file in use and find this
CSS:
.video-fluid {
max-width: 100%;
}
Replace that block with the following
CSS:
/* Fluid video/img */
.video-fluid,
.site-image-container video:not(.video-fluid) {
max-width: 100%;
}
.img-fluid,
.site-image-container img:not(.img-fluid) {
height: auto;
}
@supports (--custom:property) {
.site-image-container {
position: relative;
display: block;
max-width: var(--site-image-aspect-base);
}
.site-image-container::before {
content: "";
display: block;
padding-bottom: calc(100% / (var(--site-image-aspect-ratio)));
}
.site-image-container img,
.site-image-container video {
position: absolute;
top: 0;
left: 0;
height: 100%;
object-fit: fill;
}
}