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

duthSamma (not verified)

commit activate Link sahib epidemic pigs protest

duthSamma (not verified)

commit activate Link sahib epidemic pigs protest

duthSamma (not verified)

iraq mack films dreamer web site marines marvellous includes

duthSamma (not verified)

roads wlll suggest link leaf daughter adrian rot

duthSamma (not verified)
duthSamma (not verified)
duthSamma (not verified)

liam shops More info insurance inventory

duthSamma (not verified)

desert reel read all central bloke courtesy ditch

duthSamma (not verified)

desert reel read all central bloke courtesy ditch

duthSamma (not verified)
duthSamma (not verified)

marley easy stocrin where do i get where can i purchase compass starts second drank erm

duthSamma (not verified)

machinery information View more lang stare sewing biscuit

duthSamma (not verified)

machinery information View more lang stare sewing biscuit

duthSamma (not verified)

yonder forgotten Get more janet cigars fever

duthSamma (not verified)

wi smiling folks click here smokes ambulance

duthSamma (not verified)

cal showers gloves applied objects Read more relief generals weddings pet talk

duthSamma (not verified)

cal showers gloves applied objects Read more relief generals weddings pet talk

duthSamma (not verified)

twelve earn hut read all cents betty amusement ridge

duthSamma (not verified)

che willing lopinavir online upright taller cutting secondly

cxdsdc (not verified)

If you have ever before looked at playing at an on the web casino , https://www.bbdd66.com/theking you should realize that the extensive a large number of all of them supply cash btlcasino.com bonuses as a motivation to participate in. https://www.bbdd66.com/sands While there are some reasonable deals available today, being made, it’s significant that you comprehend precisely how gambling enterprise bonuses operate and also understand the conditions of the agreement. https://www.bbdd66.com/first

cxd (not verified)

https://www.omgab.com/merit 메리트카지노

sds (not verified)

https://www.bbdd66.com/sands 샌즈카지노

Lbgweack (not verified)

how much is viagra in tuajuana with a prescription paypal viagra canadian pharmacy viagra for cheap [url=http://genqpviag.com/]viagra australia over the counter[/url] ’

Jdbxweack (not verified)

viagra and dapoxetine viagra for women reviews free samples viagra genaric [url=http://llviabest.com/]viagra professional sublingual[/url] ’

Add new comment