Thursday, March 15, 2018

[CSS] Set youtube embed video to width 100%

This is a method set youtube embed video width without using width and height attribute.
<html>
<head>
    <style>
    .video {
        position: relative;
        width: 100%;
        height: 0;
        padding-bottom: 56.25%;
    }
    .video iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
    </style>
</head>
<body>
<div class="video">
    <iframe src="https://www.youtube.com/embed/PPnFaCZSjcc?rel=0"></iframe>
</div>
</body>

No comments :

Post a Comment