Answer the question
In order to leave comments, you need to log in
Fullwidth responsive block from Youtube video without black borders?
How can I put an iframe inside a block, while the width of the block should be the width of the entire screen and the height should be fixed (for example 300px or 20vh) while cutting off the black borders both horizontally and vertically?
Perhaps there are libraries for this implementation, publishing video in the background for divs?
<div class="video-block">
<iframe id="video" width="100%" height="100%" src="https://www.youtube.com/embed/YpDp5Y5X3iU?rel=0&&loop=1&controls=0&&modestbranding=1&showinfo=0&autoplay=1&controls=0&autohide=1&frameborder=1" allowfullscreen></iframe>
</div>
Answer the question
In order to leave comments, you need to log in
.videoWrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
}
.videoWrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question