M
M
Mixa2016-01-04 14:34:25
YouTube
Mixa, 2016-01-04 14:34:25

How to make iframe inserts responsive?

It is surprising that in the age of responsive design, various services that allow you to embed your content still use fixed values. What if you want all the videos and other crap inserted on the site through iframes not to break the appearance of the site when viewed from mobile devices?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Khristoev, 2016-01-04
@Haoss

.video {
    position: relative;
    overflow: hidden;
    height: 0;
    padding-bottom: 54.15%;
}
.video iframe, 
.video object, 
.video embed {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

D
Denis Ineshin, 2016-01-04
@IonDen

So set the iframe with YouTube as a percentage. He is quite capable of it.
Similarly, you can resize an iframe on media queries, think of it like a picture.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question