* Graham
This is a elegant trick to create a responsive youtube embedded iframe video
add this css to your stylesheet
/* This element defines the size the iframe will take.
       In this example we want to have a ratio of 25:14 */
    .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;
    }

Copy code
And then add your youtube iframe like this
<div class="aspect-ratio"><iframe src="https://www.youtube.com/embed/YOUTUBE VIDEO ID CODE GOES HERE" width="550" height="275" frameborder="0" allowfullscreen="allowfullscreen"></iframe></div>
Copy code
the iframe will resize to the limit of the container but retain the correct aspect ratio
demo http://baretest.xtgem.com/tubeframe
2017-04-17 10:19 (edited 2017-04-17 10:49 by Graham ) · (0)

Online: Guests: 1