How did YouTube create a fluid video player?

Here is a solution with only CSS:

.embed-container {
  position: relative;
  padding-bottom: 56.25%; /* 16x9 */
  height: 0;
  overflow: hidden;
  max-width: 100%;
}

.embed-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0
}
<div class="embed-container">
  <iframe src="https://www.youtube.com/embed/C0DPdy98e4c"></iframe>
</div>

Leave a Comment