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

Prednisone (not verified)

Viagra Generique Arrow

gabapentin mech... (not verified)

cialis tadalafil beter dan viagra

Neurontine (not verified)

cialis chewable

side effects of... (not verified)

Propecia Rae

prednisone moon face (not verified)

Prueba Gratuita De Viagra

what are the si... (not verified)

Length Of Levitra Patent

gabapentin dosage (not verified)

Viagra Bestellen Serios

Neurontine (not verified)

Viagra Pour Bebe

Prednisone (not verified)

Baclofene Internet

neurontin for n... (not verified)

Isotretinoin price

where to buy pr... (not verified)

Cialis En Farmacia Sin Receta

Neurontine (not verified)

Viagra Effets Negatifs

cheap cialis ge... (not verified)

Celebrex Discount Card Pfizer

cheap cialis (not verified)

Is Keflex Good For Teeth Nfection

Cialis (not verified)

Acheter Cialis Occasion

buy viagra onli... (not verified)

How To Take Amoxicillin 1000 Mg

cheapest cialis 20mg (not verified)

Commande Cialis Generic

Propecia (not verified)

buy levitra line

Viagra (not verified)

Le Viagra Ordonnance

Viagra (not verified)

Fast Delivery Viagrabest Online Price

Viagra (not verified)

Priligy Si Trova In Farmacia

Lasix (not verified)

Acyclovir No Script

kamagra viagra uk (not verified)

Propecia Cancer Testicular

viagra and copd (not verified)

Cuanto Vale Cialis

how much does c... (not verified)

Acheter Kamagra Bon Marche

cheapest finast... (not verified)

Amoxicillin And Daily Dosage

Cialis (not verified)

Viagra Blu

Lasix (not verified)

Buy Online Viagra Pfizer From Pakistan

buy cialis 5mg ... (not verified)

foros cialis sin receta

Cialis (not verified)

Kamagra Francais Acheter

best price 1mg ... (not verified)

levitra dolor de espalda

buy cialis with... (not verified)

Macrobid Urinary Tract Infections

purchase cialis... (not verified)

Line Pharmacy Levitra

Viagra (not verified)

Cialis Achat En Ligne Canada

buy cialis prof... (not verified)

Viagra Buy Uk Amsterdam

tadalafil cialis (not verified)

Online Acticin Buy Now

finasteride 1 m... (not verified)

Efecto De Kamagra

Propecia (not verified)

Buy Silagra 100 Mg

Propecia (not verified)

Secure Ordering Bentyl

Stromectol (not verified)

Amoxicillin 250 Gg 848

buy cialis onli... (not verified)

Como Comprar Cialis En Espana

viagra force online (not verified)

Buy Generic Celebrex Online

Propecia (not verified)

Reputable Online Levitra

side effects of... (not verified)

Cialis 20mg No 12

Viagra (not verified)

Buycheapviagrausa

Prednisone (not verified)

Medsindia

priligy and viagra (not verified)

Peut Acheter Kamagra Pharmacie

Priligy (not verified)

Real Generic Dutasteride Online

Lasix (not verified)

Himcolin

Lasix (not verified)

Does Amoxicillin Affect Pap Smear