A
A
Alexey2017-09-13 10:20:27
YouTube
Alexey, 2017-09-13 10:20:27

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&amp&loop=1&controls=0&amp&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

1 answer(s)
A
Alexander Borisovich, 2017-09-13
@azovl

.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%;
}

https://css-tricks.com/NetMag/FluidWidthVideo/Arti...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question