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

Illeclima (not verified)

http://buyneurontine.com/ - gabapentin medication

Prednisone (not verified)

Viagra Generique Arrow

urgetty (not verified)

buy prednisone from india

urgetty (not verified)

Prednisone

gabapentin mech... (not verified)

cialis tadalafil beter dan viagra

urgetty (not verified)

Prednisone

chonula (not verified)

Neurontine

chonula (not verified)

Neurontine

Illeclima (not verified)

http://buyneurontine.com/ - Neurontine

Nepeazy (not verified)

http://prednisonebuyon.com/ - online pharmacy to order prednisone

chonula (not verified)

Neurontine

Illeclima (not verified)

http://buyneurontine.com/ - gabapentin 400mg

Illeclima (not verified)

http://buyneurontine.com/ - Neurontine

Nepeazy (not verified)

https://prednisonebuyon.com/ - prednisolone for eczema

chonula (not verified)

Neurontine

Neurontine (not verified)

cialis chewable

Nepeazy (not verified)

http://prednisonebuyon.com/ - prednisolone reviews

Illeclima (not verified)

http://buyneurontine.com/ - Neurontine

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

chonula (not verified)

the side effects of gabapentin

urgetty (not verified)

where can i buy prednisone no prescription

Neurontine (not verified)

Viagra Pour Bebe

chonula (not verified)

gabapentin dosage for sleep

Prednisone (not verified)

Baclofene Internet

chonula (not verified)

gabapentin moa

Illeclima (not verified)

https://buyneurontine.com/ - Neurontine

urgetty (not verified)

what is prednisone

Nepeazy (not verified)

https://prednisonebuyon.com/ - Prednisone

neurontin for n... (not verified)

Isotretinoin price

urgetty (not verified)

refill prednisone

GustavoJAl (not verified)

write my paper cheap
custom essay service

where to buy pr... (not verified)

Cialis En Farmacia Sin Receta

Illeclima (not verified)

http://buyneurontine.com/ - neurontin 600 mg

Neurontine (not verified)

Viagra Effets Negatifs

MatthewCap (not verified)

resume writing services nyc
essay writers for hire

Dnyuaerop (not verified)

wat kost viagra via huisarts viagra 010

SnukJats (not verified)

watermelon same as viagra how often can one use viagra

cheap cialis ge... (not verified)

Celebrex Discount Card Pfizer

cheap cialis (not verified)

Is Keflex Good For Teeth Nfection

knockadia (not verified)

Cialis

freerurgy (not verified)

online finasteride prescription

Cialis (not verified)

Acheter Cialis Occasion

buy viagra onli... (not verified)

How To Take Amoxicillin 1000 Mg

Cafeseast (not verified)

Cialis

cheapest cialis 20mg (not verified)

Commande Cialis Generic

Propecia (not verified)

buy levitra line

freerurgy (not verified)

Propecia

Add new comment