Responsive Youtube Embed | Make YouTube Videos Responsive

.embed-youtube {
    position: relative;
    padding-bottom: 56.25%; /* - 16:9 aspect ratio (most common) */
    /* padding-bottom: 62.5%; - 16:10 aspect ratio */
    /* padding-bottom: 75%; - 4:3 aspect ratio */
    padding-top: 30px;
    height: 0;
    overflow: hidden;
}

.embed-youtube iframe,
.embed-youtube object,
.embed-youtube embed {
    border: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

Example:

<div class="embed-youtube"><iframe title="YouTube video player" src="https://www.youtube.com/embed/mgDWHxeVaAs" frameborder="0" allowfullscreen="allowfullscreen"></iframe></div>

Related Posts


XAMPP – Error: MySQL shutdown unexpectedly

Generally there are four possible reason for XAMPP – Error: MySQL shutdown unexpectedly. 1. Sk...

Creating a Responsive YouTube Video iframe for Seamless Integration

Introduction: In the dynamic world of web development, creating a responsive design is crucial for p...

What is MySQL? A Comprehensive Guide

Have you ever wondered what MySQL, a source relational database management system, is and how it wor...

Creating a React Project: Step-by-Step Guide

Ready to dive into the world of React? Want to create your own React project from scratch? In this t...