| |

How to make video iframe responive?

How to make video iframe responive? Copy the CSS below and make sure that there is a ” iframe-wrap ” before the iframe element.

CSS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
.iframe-wrap {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    max-width: 100%;
}
.iframe-wrap iframe,
.iframe-wrap object,
.iframe-wrap embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

HTML

1
2
3
<div class='iframe-wrap'>
    <iframe src='https://www.youtube.com/embed/xRM99Srkvas' frameborder='0' allowfullscreen></iframe>
</div>

Similar Posts

Leave a Reply

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