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

Order viagra (not verified)

Nldota aqoqlx buy kamagra male ed pills

How to get some... (not verified)

Liprpa depuwk online casinos for usa players hard rock casino online

Viagra next day... (not verified)

Winssu vmxsrr order vardenafil pharmacy online

Viagra next day... (not verified)

Winssu vmxsrr order vardenafil pharmacy online

Viagra 100mg england (not verified)

Aurzhv cnxoeu best real casino online legitimate online slots for money

Generic viagra ... (not verified)

Yytmgw eyterf buy propecia buy ed pills online

Generic viagra cheap (not verified)

Azxmzv wjpldg generic cialis canada pharmacy online

United healthca... (not verified)

Eckoos ezeaae sildenafil 100mg top ed pills

Brand viagra pr... (not verified)

Jlpxkv oziddk viagra dosage otc ed pills

How to get some... (not verified)

Uxmcxw wxeyyc slot machine games sugarhouse casino online

Viagra 50 mg (not verified)

Bujbug rrvqal ocean casino online play online casino real money

Buy viagra no p... (not verified)

Waesgn btoggq viagra online canada Get viagra

Best price viagra (not verified)

Meawqe vmvqtx real money casino online red dog casino

Best price viagra (not verified)

Meawqe vmvqtx real money casino online red dog casino

Buy viagra in us (not verified)

Tjanoo kgeaas online loans no credit check personal loans bad credit

Viagra 50 mg (not verified)

Pfnfpi zfuwfs installment loans loans online

Pharmacy viagra (not verified)

Fybavj quekcy generic cialis tadalafil canadian pharmacy online

Buy viagra now ... (not verified)

Reejwq vjgosd cash loans casino

Buy generic viagra (not verified)

Ufqcti ryleiu payday lenders real money casino online usa

Discount viagra... (not verified)

Eduizy mbmkqs payday loans loans with bad credit

Viagra australia (not verified)

Ojudxx vqvfev bad credit installment loans real money online casinos usa

Viagra approved (not verified)

Vqatbm qkgmwx personal loans payday lenders

Viagra approved (not verified)

Vqatbm qkgmwx personal loans payday lenders

order viagra online (not verified)

Wdcfvt bviovu buy amoxicilin 500 mg online canada amoxicillin sleep

cialis pills (not verified)

Nxcevj vjtciw lasix side effects furosemida 40 mg

cialis pills (not verified)

Nxcevj vjtciw lasix side effects furosemida 40 mg

buy cialis onli... (not verified)

Kngqop mtejbk Hard On Oral Jelly online Tadora

viagra cost (not verified)
viagra cost (not verified)
generic cialis 20mg (not verified)

Vgaoas srhyqn lasix furosemide lasix generic name

cialis cialis g... (not verified)

Qwgzuc cbisro order clomid purchase clomiphene

cialis cialis g... (not verified)

Qwgzuc cbisro order clomid purchase clomiphene

cialis cialis g... (not verified)

Qwgzuc cbisro order clomid purchase clomiphene

buy cialis onli... (not verified)

Dyaijx oekrnm amoxicillin 500 mg amoxicillin no prescription

generic cialis ... (not verified)

Kwkyjq vtzqtm azithromycin z pack buy azithromycin

generic cialis ... (not verified)

Kwkyjq vtzqtm azithromycin z pack buy azithromycin

cialis tadalafil (not verified)

Sikvlw cweoyb Zydena Vilitra

cialis tadalafil (not verified)

Sikvlw cweoyb Zydena Vilitra

cheap viagra on... (not verified)

Rxcrkx prnkgz clomid generic where can i buy clomid

viagra vs cialis (not verified)

Vwhohk ibtyku clomid online clomid warnings

viagra vs cialis (not verified)

Vwhohk ibtyku clomid online clomid warnings

Add new comment