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

Estherchera (not verified)

Hnygwk jypdhm best canadian online pharmacy best online pharmacy

Estherchera (not verified)

Nffpwc rgjogs online pharmacy canada online canadian pharmacy

Estherchera (not verified)

Fszqab gmfidn Generic viagra usa Generic viagra

Estherchera (not verified)

Pmwgza gwfiqb Viagra overnight delivery Viagra jelly

Estherchera (not verified)

Kpkkjl gifxyy Buy viagra no prescription Canadian pharmacy viagra legal

Estherchera (not verified)

Kpkkjl gifxyy Buy viagra no prescription Canadian pharmacy viagra legal

Estherchera (not verified)

Mifwcb pqzckw Buy viagra online pharmacy online

Estherchera (not verified)

Cgsscb ulyoac Cialis overnight shipping canada online pharmacy

Estherchera (not verified)

Cgsscb ulyoac Cialis overnight shipping canada online pharmacy

Varshini (not verified)

Nice post. Useful information. This is always happy to know about Salesforce training in Gurgaon whose certification program helps many to get certificed. I strongly urge you to join now in Salesforce Training in Hyderabad | Course Price | Training institute and enroll for free demo at Salesforce Training in Bangalore | Course Certification Cost and Job Placement Assistance . I have gone through this Salesforce Certification Training. Why done you enroll for a free demo at Salesforce training institutes in Chennai [updated] | Course Price

Estherchera (not verified)

Ppyjbm hwipqm Buy cialis in us rx pharmacy

Estherchera (not verified)

Uvmzeh hsuvon Get cialis walmart pharmacy

Order viagra usa (not verified)
Low cost canadi... (not verified)

Lxxnhj jrhspu buy levitra online

Viagra original... (not verified)

Arfxqf mellea vardenafil pills

Buy cheap viagra (not verified)

Rbozmc hbhmqb vardenafil coupon ed pills online

Buy cheap viagra (not verified)

Rbozmc hbhmqb vardenafil coupon ed pills online

Buy cheap viagra (not verified)

Rbozmc hbhmqb vardenafil coupon ed pills online

Buy cheap viagra (not verified)

Rbozmc hbhmqb vardenafil coupon ed pills online

Order viagra (not verified)

Nldota aqoqlx buy kamagra male ed pills

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

Add new comment