Answer the question
In order to leave comments, you need to log in
Html code for a YouTube video, is it possible to stretch height relative to width?
What can be specified in height so that the height automatically adjusts to the width and there is no black background on the sides of the video? auto <- doesn't work.
<iframe width="100%" height="" src="https://www.youtube.com/embed/Zh1zprk92s8" frameborder="0" allowfullscreen></iframe>
Answer the question
In order to leave comments, you need to log in
.video {
height: 0;
position: relative;
padding-bottom: 56.25%;
}
.video iframe {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
thanks a lot.
I'll just add for the pioneers:
<div class="video">
<iframe id="youtube1" width="100%" src="https://www.youtube.com/embed/nWdInJYfcOY?controls=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question