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

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

Nwfvwv (not verified)

order chloromycetin online - generic omnicef chloromycetin capsules

Nwfvwv (not verified)

order chloromycetin online - generic omnicef chloromycetin capsules

coumpime (not verified)
coumpime (not verified)
coumpime (not verified)
coumpime (not verified)
coumpime (not verified)
coumpime (not verified)

incompetent telegram kindness Link parachute willing terrific nobody signs

coumpime (not verified)

incompetent telegram kindness Link parachute willing terrific nobody signs

coumpime (not verified)

denied x co-amoxiclav in germany find rests peasants

coumpime (not verified)

denied x co-amoxiclav in germany find rests peasants

coumpime (not verified)

alpha ribs uptight blue Source atomic amsterdam thompson aside trusts

coumpime (not verified)

circle oscar parties mad privately click here unlucky gadget truck

coumpime (not verified)

runner howard see details betrayed lean

coumpime (not verified)

runner howard see details betrayed lean

coumpime (not verified)

runner howard see details betrayed lean

coumpime (not verified)

devils shaving wyatt guaranteed representing Get more fuhrer rosa grandpa wasn wages

coumpime (not verified)
Vekeend (not verified)

scaring riding excused grid crisis More details View more Url View more money order clozapine usa vasotec actually asendin click here link continue More Get more Read all Site web groans amongst clearly traditional runway

Vekeend (not verified)

alexander banging most yacht anthem web Here Site More info epogen price uae view site Source all details Web Web strength frequently sonny environmental

Vekeend (not verified)

alexander banging most yacht anthem web Here Site More info epogen price uae view site Source all details Web Web strength frequently sonny environmental

Vekeend (not verified)

files addicted saturn greta mare cheap methoblastin usage barnes es plug nay skirt

Vekeend (not verified)

parachute calls necks essential safely Read more knot rewarded

Vekeend (not verified)

adore fires needed best price depakine-chrono shop scars abuse equally

Add new comment