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


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...

How can I prevent SQL injection in PHP?

SQL injection is one of the most common and dangerous vulnerabilities in web applications. Attackers...

XAMPP – Error: MySQL shutdown unexpectedly

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