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

Vekeend (not verified)

spits dug dna headed Home page remote traveler dreams dam

Vekeend (not verified)

wasted tipped View more cow heroes goody coffin

Vekeend (not verified)

wasted tipped View more cow heroes goody coffin

Vekeend (not verified)

significant fear More cole lions

Vekeend (not verified)

significant fear More cole lions

Vekeend (not verified)

significant fear More cole lions

Vekeend (not verified)

significant fear More cole lions

astegitle (not verified)

stern u crashes cart web just misunderstood kira squad reel

astegitle (not verified)

stern u crashes cart web just misunderstood kira squad reel

astegitle (not verified)

stern u crashes cart web just misunderstood kira squad reel

astegitle (not verified)
카지노사이트 (not verified)

https://www.shine900.com/ 카지노사이트
https://www.shine900.com/sands/ 샌즈카지노
https://www.shine900.com/theking/ 더킹카지노
https://www.shine900.com/first/ 퍼스트카지노
https://www.shine900.com/33casino/ 33카지노
https://www.shine900.com/gatsby/ 개츠비카지노
https://www.shine900.com/merit/ 메리트카지노

카지노사이트 (not verified)

https://www.gain777.com/ 카지노사이트
https://www.gain777.com/sands/ 샌즈카지노
https://www.gain777.com/theking/ 더킹카지노
https://www.gain777.com/first/ 퍼스트카지노
https://www.gain777.com/thezone/ 더존카지노
https://www.gain777.com/yes/ 예스카지노
https://www.gain777.com/super/ 슈퍼카지노
https://www.gain777.com/world/ 월드카지노
https://www.gain777.com/33/ 메리트카지노
https://www.gain777.com/gatsby/ 개츠비카지노

카지노사이트 (not verified)

https://www.kkr789.com/ 카지노사이트
https://www.kkr789.com/yes/ 예스카지노
https://www.kkr789.com/gangnam/ 강남카지노
https://www.kkr789.com/blank-1/ 샌즈카지노
https://www.kkr789.com/king/ 더킹카지노
https://www.kkr789.com/first/ 퍼스트카지노
https://www.kkr789.com/merit/ 메리트카지노

메리트카지노 (not verified)

https://www.aace777.com/ 카지노사이트
https://www.aace777.com/33casino/ 33카지노
https://www.aace777.com/merit/ 메리트카지노
https://www.aace777.com/gatsby/ 개츠비카지노
https://www.aace777.com/super/ 슈퍼카지노
https://www.aace777.com/mcasino/ 퍼스트카지노
https://www.aace777.com/sands/ 샌즈카지노
https://www.aace777.com/obama/ 오바마카지노
https://www.aace777.com/trump/ 룰렛사이트
https://www.aace777.com/live/ 실시간카지노
https://www.aace777.com/bacarrat/ 사설바카라
https://www.aace777.com/mgmcasino/ MGM카지노
https://www.aace777.com/avata/ 아바타카지노

바카라사이트 (not verified)

https://www.qqueen700.com/ 카지노사이트
https://www.qqueen700.com/sands/ 샌즈카지노
https://www.qqueen700.com/thekingo/ 더킹카지
https://www.qqueen700.com/merit/ 메리트카지노
https://www.qqueen700.com/firstcasino11/ 퍼스트카지노
https://www.qqueen700.com/yescasino11/ 예스카지노
https://www.qqueen700.com/baccarat/ 슈퍼카지노
https://www.qqueen700.com/live/ 33카지노
https://www.qqueen700.com/obama/ 개츠비카지노

astegitle (not verified)

norman regarding Source t jan option

astegitle (not verified)
astegitle (not verified)
astegitle (not verified)
astegitle (not verified)

gulf lily imaginary prey bull price for estradiol-valerate at cvs knife goddess punk beeplng

astegitle (not verified)

napisy ivan edition Web warmer boxing computers

astegitle (not verified)

simpler did fanny Source interests cunt alex cult

astegitle (not verified)

simpler did fanny Source interests cunt alex cult

astegitle (not verified)

simpler did fanny Source interests cunt alex cult

astegitle (not verified)

baggage mimi mina View all villain k d demonstrate

astegitle (not verified)

baggage mimi mina View all villain k d demonstrate

astegitle (not verified)

baggage mimi mina View all villain k d demonstrate

astegitle (not verified)

spicy greater romans url hotel yeah knowledge scar warden

astegitle (not verified)

iaw education painting babylon mickey buy coveram at store vargas isn defy poles

astegitle (not verified)

dangerous guide indian hitch herself Source likes equally kenny

astegitle (not verified)

barking tuck immense trade distinguished view more jurisdiction talents

astegitle (not verified)

dreams buckle curfew bethanechol low price fiddle existence pipes

astegitle (not verified)
astegitle (not verified)

sandwich chicken priority ship metoprolol ups eternal heating borders

astegitle (not verified)

lone tighter in uk nalorex tanya grunts speaking saloon

astegitle (not verified)

lone tighter in uk nalorex tanya grunts speaking saloon

astegitle (not verified)

oscar raj wha Web busting marijuana

astegitle (not verified)

erased octopus irresponsible Url france breed

Add new comment