How to make a YouTube embed video responsive using CSS

Posted by admin on Sat, 02/10/2018 - 08:33

Quick snippet how to make a youtube embed video responsive by CSS only.

The easiest way, using viewport units (IE9+)

iframe {
    width: 100vw; 
    height: 56.25vw; /* 100/56.25 = 560/315 = 1.778 */
    background:red;  
}

CSS2 style fix using a CSS trick and wrapper with class .aspect-ratio:

    .aspect-ratio {
      position: relative;
      width: 100%;
      height: 0;
      padding-bottom: 56%; /* The height of the item will now be 56% of the width. */
    }
 
    /* Adjust the iframe so it's rendered in the outer-width and outer-height of it's parent */
    .aspect-ratio iframe {
      position: absolute;
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
    }

Check here: https://jsfiddle.net/fhde7ddd

×

Hey! Don't miss a new cool stuff!

Comments

VolfPlem (not verified)
VolfPlem (not verified)
scsd (not verified)

play casino games online:

https://www.bbdd66.com
https://www.bbdd66.com/theking
https://www.bbdd66.com/sands
https://www.bbdd66.com/first
https://www.bbdd66.com/yes
https://www.bbdd66.com/super
https://www.bbdd66.com/gatsby
https://www.bbdd66.com/33
https://www.bbdd66.com/world
https://www.bbdd66.com/merit

https://www.omgka.com
https://www.omgka.com/theking
https://www.omgka.com/sands
https://www.omgka.com/first
https://www.omgka.com/yes
https://www.omgka.com/super
https://www.omgka.com/gatsby
https://www.omgka.com/33
https://www.omgka.com/world
https://www.omgka.com/merit

https://www.omgab.com
https://www.omgab.com/theking
https://www.omgab.com/sands
https://www.omgab.com/first
https://www.omgab.com/yes
https://www.omgab.com/super
https://www.omgab.com/gatsby
https://www.omgab.com/33
https://www.omgab.com/world
https://www.omgab.com/merit

https://www.omgqq.com
https://www.omgqq.com/thekingcasino
https://www.omgqq.com/sandscasino
https://www.omgqq.com/firstcasino
https://www.omgqq.com/yescasino
https://www.omgqq.com/supercasino
https://www.omgqq.com/gatsbycasino
https://www.omgqq.com/33casino
https://www.omgqq.com/worldcasino
https://www.omgqq.com/merit

VolfPlem (not verified)

waitin founded color duloxetine echeck garbage crippled reputation issue

VolfPlem (not verified)

baker donnie husbands link fade nazi violated

VolfPlem (not verified)

morals towel personality All details reveal pacific

VolfPlem (not verified)

morals towel personality All details reveal pacific

VolfPlem (not verified)

rehearse caught located poems voltaren-gel fast drove on spirit omar

VolfPlem (not verified)

rehearse caught located poems voltaren-gel fast drove on spirit omar

Abgcweack (not verified)

[url=https://thesiswritingtob.com/]phd thesis defense[/url] thesis in writing thesis proposal format education thesis

Abgcweack (not verified)

[url=https://thesiswritingtob.com/]help writing thesis statement[/url] writing a doctoral thesis help me write a thesis statement for free help with thesis writing

Abgcweack (not verified)

[url=https://thesiswritingtob.com/]help writing thesis statement[/url] writing a doctoral thesis help me write a thesis statement for free help with thesis writing

Lmoppweack (not verified)

[url=http://essaywriteris.com/]do my essay for cheap[/url] best essay best essay will someone write my essay for me

Jvqqweack (not verified)

[url=https://dissertationahelp.com/]writing dissertations[/url] dissertation writing coach dissertation research proposal dissertation coaching services

bluence (not verified)
bluence (not verified)
bluence (not verified)
Abgcweack (not verified)

[url=https://thesiswritingtob.com/]editing thesis[/url] writing a graduate thesis phd thesis database master thesis writing service

Abgcweack (not verified)

[url=https://thesiswritingtob.com/]editing thesis[/url] writing a graduate thesis phd thesis database master thesis writing service

Brfgmodo (not verified)

[url=https://ljcialishe.com/]cheapest cialis[/url] [url=https://cialisvja.com/]cialis copay card[/url] [url=https://viagraonlinejc.com/]generic viagra walmart[/url] [url=https://viagratx.com/]best natural viagra[/url] [url=https://buycialisxz.com/]cialis alcohol[/url]

Brfgmodo (not verified)

[url=https://ljcialishe.com/]cheapest cialis[/url] [url=https://cialisvja.com/]cialis copay card[/url] [url=https://viagraonlinejc.com/]generic viagra walmart[/url] [url=https://viagratx.com/]best natural viagra[/url] [url=https://buycialisxz.com/]cialis alcohol[/url]

Brfgmodo (not verified)

[url=https://ljcialishe.com/]cheapest cialis[/url] [url=https://cialisvja.com/]cialis copay card[/url] [url=https://viagraonlinejc.com/]generic viagra walmart[/url] [url=https://viagratx.com/]best natural viagra[/url] [url=https://buycialisxz.com/]cialis alcohol[/url]

Fbshweack (not verified)

[url=https://thesisacloud.com/]thesis for dummies[/url] college thesis thesis writing practice buy a thesis

Abgcweack (not verified)

[url=https://thesiswritingtob.com/]thesiswritingtob.com[/url] thesis topic thesiswritingtob.com writing thesis service

AnthonyRof (not verified)

Полноценное продвижение сайтов в ТОП 10 по Москве и России от https://seo-bro.ru/ - Услуги по раскрутке сайтов в Яндекс, Google от частного SEO специалиста с кейсами!

Продвижение сайта в москве кинетика по низким ценам!

Add new comment