Make a YouTube video responsive with CSS

Make a YouTube video responsive with CSS

YouTube is world’s most popular video streaming site, so if you have a responsive website and want to embed a youtube video on a page , you can just do using youtube embed code but it will not going to support your smart phone , simply its not responsive, In this video I am going to show you how to make youtube video responsive in all device using CSS code.

CSS Code to make Youtube video Responsive

.youtube{
    float: none;
    clear: both;
    width: 100%;
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 25px;
    height: 0;
}
.youtube iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

HTML code to make youtube video responsive


<div class="youtube">
<iframe width="560" height="315" src="https://www.youtube.com/embed/lqoNpmmzy_0" frameborder="0" allowfullscreen></iframe>
</div>

OUTPUT

Leave a Reply

Your email address will not be published. Required fields are marked *

Do you have any Query / Suggestion