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

test (not verified)

test

Sfhhst c (not verified)

Ygxfea tbkhgq viagra generic

Sfhhst c (not verified)

Ygxfea tbkhgq viagra generic

Order viagra us (not verified)

Puytyz ooelcc sildenafil generic Buy cheap viagra internet

How to get viagra (not verified)

Dfxrdn hzdkhp best place to buy generic viagra Canadain viagra

How to get viagra (not verified)

Dfxrdn hzdkhp best place to buy generic viagra Canadain viagra

Buy real viagra... (not verified)

Oqwjly mcyzfn when is viagra generic Buy viagra com

Generic viagra us (not verified)

Entlce mbejjf generic viagra online usa Canadian healthcare viagra

Sample viagra (not verified)

Kxstui ozdkhb Low cost canadian viagra Canadian generic viagra online

Discount viagra... (not verified)

Ebzons ebrxce Canadian healthcare viagra Cost of viagra

Order viagra wi... (not verified)

Inaadi linuao Viagra overnight Get viagra fast

Buy viagra in canada (not verified)

Qlduxp sigdxd erectile dysfunction medication Generic viagra in canada

Viagra or cialis (not verified)

Djupxz xpjojl Buy viagra in us Free viagra

Viagra pfizer (not verified)

Uzxxer fvuywq Real viagra online Viagra overnight shipping

Viagra pfizer (not verified)

Xuvdhq wurcrl cheap viagra generic best price Order viagra online

Estherchera (not verified)

Pizjqp ismyru sildenafil without a doctor's prescription Overnight delivery viagra

Estherchera (not verified)

Tsetwf khbsex Buy online viagra Brand viagra

impotence pills (not verified)

Snnnjt nifcxd ed meds cheap erectile dysfunction pill

male erection pills (not verified)

Tqxswx koiweh best erection pills ed pills online

best ed pills at gnc (not verified)

Itbxwc yvxuhr ed medications new ed pills

best ed pills (not verified)

Kowkit dnqidv ed meds cheap erectile dysfunction

ed pills that r... (not verified)

Yktgqj jdjecz discount cialis erection pills online

Deepa (not verified)

Gone through this wonderful coures called Salesforce Certification Training in Dallas who are offering fully practical course, who parent is Salesforce Training in USA and they have students at Salesforce Training classes in Canada institutes.

Estherchera (not verified)

Vcxtrc kbnzzs viagra online Real viagra online

Estherchera (not verified)

Vcxtrc kbnzzs viagra online Real viagra online

Vinny (not verified)

I am so happy to found your blog post because it's really very informative. Please keep writing this kind of blogs and I regularly visit this blog. Have a look at my services.  
This is really the best Top 20 Salesforce CRM Admin Development Interview Questions highly helpful. I have found these Scenario based Salesforce developers interview questions and answers very helpful to attempt job interviews. Wow, i got this scenario based Salesforce interview questions highly helpful.

Anonymous (not verified)

Myself so glad to establish your blog entry since it's actually quite instructive. If it's not too much trouble continue composing this sort of web journals and I normally visit this blog. Examine my administrations.  
Read these Salesforce Admin Certification Topics which are really helpful. I read these Salesforce Admin and Developer Certification Dumps and very much useful for me. I recommend this Salesforce Developer Training and Certification Course for you.

Nick (not verified)

Great post! I am actually getting ready to across this information, It’s very helpful for this blog. Also great with all of the valuable information you have Keep up the good work you are doing well.
CRS Info Solutions Salesforce training for beginners

Add new comment