When embedding a Youtube video iframe, it is important to ensure that it scales according to the width of the containing div. The width of the div can vary depending on the layout of the page snippet.
The aspect ratio of the Youtube video is 560/315, width/height.
In my attempts, I noticed that the height of the Youtube iframe is too short, causing the thumbnail to be cropped.
However, upon closer inspection, it seems that it is actually the thumbnail that is cropped. Once the video is played, the aspect ratio adjusts accordingly...
But the video appears too narrow and tiny because it is constrained by the height of the iframe container, which is too short.
This issue has been observed on the latest versions of Firefox and Chrome.
Are there any recommendations on how to adjust the display to ensure the video maintains the correct aspect ratio within the container div?
For reference, please visit https://codepen.io/iamalta/pen/MMwwwK
Video link: https://www.youtube.com/watch?v=UDV161pAcUU
HTML CODE:
<div class="col-12">
<div class="left col-6">
<iframe class="left youtube" src="https://www.youtube.com/embed/UDV161pAcUU" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
</iframe>
</div>
<div class="left col-6">
<div class="p1">
This Tropical Water Lily Preview Video shows Tricker's and the wonderful world of Tropical Water
Lilies. Some scenes are from our DVD Introduction to Water Gardening. Purchase entire DVD.
</div>
<div class="clearfix"></div>
<div class="col-12 p0">
<img src="https://www.tricker.com/media/ecom/description/redtropicalheading1.jpg" class="img-100-auto" />
</div>
</div>
</div>
CSS
.youtube{
width: 560px;
height: 315px;
max-width: 100%;
height: 56.25%;
}
.img-100-auto{width:100%;height:auto}
.clearfix:after, .clearfix:before{content:" ";display:table}
.clearfix:after{clear:both}
.col-6{width:50%}
.col-12{width:100}
.left{float:left}
.p1{padding:rem}
.center{text-align:center}
We appreciate any suggestions or solutions to this issue. Thank you in advance!