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

eduwritersx.com (not verified)

how to write an essay about my life help essays Bzwubz jkxpgv

Jnridf (not verified)

non prescription viagra sildiks.com

Wzmkwf (not verified)

z pak antibiotics zithrobiot.com Jrcqts zrujnk

Hgszyq (not verified)

order clomid - https://clomisale.com / clomid online

Bewgly (not verified)

erectile dysfunction medication - https://goedpls.com/ medications for ed over the counter erectile dysfunction pills

Aempgy (not verified)

casino online slots - https://slotgmsp.com/ slot games casino games win real money

컴온 come on (not verified)

https://www.ekffo150.com/theking
https://www.ekffo150.com/merit
https://www.ekffo150.com/yes
https://www.ekffo150.com/first
https://www.ekffo150.com/sands
https://www.ekffo150.com/joy
https://www.ekffo150.com/royal
https://www.ekffo150.com/starclub
https://www.ekffo150.com/asian
https://www.ekffo150.com/superman
https://www.ekffo150.com/gatsby
https://www.ekffo150.com/33casino
https://www.ekffo150.com/ondasino
https://www.ekffo150.com

https://www.ajp4949.com/theking
https://www.ajp4949.com/merit
https://www.ajp4949.com/sands
https://www.ajp4949.com/first
https://www.ajp4949.com/33casino
https://www.ajp4949.com/worldcasino
https://www.ajp4949.com/korea
https://www.ajp4949.com/

https://www.bgj4949.com/
https://www.bgj4949.com/sands
https://www.bgj4949.com/theking
https://www.bgj4949.com/first
https://www.bgj4949.com/yes
https://www.bgj4949.com/33
https://www.bgj4949.com/world
https://www.bgj4949.com/super
https://www.bgj4949.com/korea
https://www.bgj4949.com/gatsby

pfedonline.com (not verified)

viagra canada http://pfedonline.com/ Rwcbtp rouffi

canadaxpha.com (not verified)

best online pharmacy canadian pharmacy review Ovuovr bnenpc

cialirpl.com (not verified)

buy cialis pills http://cialirpl.com/ Wmkbna cgvgoo

cadciali.com (not verified)

liquid tadalafil http://cadciali.com/ Ckrfuj cxlpwa

vigaspro.com (not verified)

viagra without a doctor prescription viagra sildenafil Xumfzs mjlldn

vigaspro.com (not verified)

viagra without a doctor prescription viagra sildenafil Xumfzs mjlldn

Chincz (not verified)

discount viagra free viagra sildenafil price

Wxfxjb (not verified)

walmart pharmacy http://canadianedpls.com/ Mwyzru gnwvhj

Cevdin (not verified)

cialis buy cialis online 20 cialis Xwohcc znfdqq

Lyjrhj (not verified)

https://vardenedp.com/ - vardenafil https://vardenedp.com/ levitra vardenafil

럭키걸 Lucky girl (not verified)

https://www.ekffo150.com/theking
https://www.ekffo150.com/merit
https://www.ekffo150.com/yes
https://www.ekffo150.com/first
https://www.ekffo150.com/sands
https://www.ekffo150.com/joy
https://www.ekffo150.com/royal
https://www.ekffo150.com/starclub
https://www.ekffo150.com/asian
https://www.ekffo150.com/superman
https://www.ekffo150.com/gatsby
https://www.ekffo150.com/33casino
https://www.ekffo150.com/ondasino
https://www.ekffo150.com

https://www.ajp4949.com/theking
https://www.ajp4949.com/merit
https://www.ajp4949.com/sands
https://www.ajp4949.com/first
https://www.ajp4949.com/33casino
https://www.ajp4949.com/worldcasino
https://www.ajp4949.com/korea
https://www.ajp4949.com/

https://www.bgj4949.com/
https://www.bgj4949.com/sands
https://www.bgj4949.com/theking
https://www.bgj4949.com/first
https://www.bgj4949.com/yes
https://www.bgj4949.com/33
https://www.bgj4949.com/world
https://www.bgj4949.com/super
https://www.bgj4949.com/korea
https://www.bgj4949.com/gatsby

Add new comment