Skip to content

Instantly share code, notes, and snippets.

@RyanRoberts
Created January 20, 2014 16:19
Show Gist options
  • Save RyanRoberts/8523195 to your computer and use it in GitHub Desktop.
Save RyanRoberts/8523195 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<h2>Video with fitVid class</h2>
<div class="fitVid">
<iframe width="560" height="315" src="//www.youtube.com/embed/kK0_OVn_uxA" frameborder="0" allowfullscreen></iframe>
</div>
<h2>Video with without the class</h2>
<iframe width="560" height="315" src="//www.youtube.com/embed/kK0_OVn_uxA" frameborder="0" allowfullscreen></iframe>
// ----
// Sass (v3.3.0.rc.2)
// Compass (v1.0.0.alpha.17)
// ----
.fitVid
position: relative
height: 0
padding-top: 56.25% // 16-9 ratio
// padding-top: 50% // 2-1 (vimeo)
// padding-top: 100% // 1-1
// padding-top: 75% // 4-3
iframe
position: absolute
z-index: 100 // tweak this
top: 0
right: 0
bottom: 0
left: 0
width: 100%
height: 100%
// Generic stuff
body
max-width: 560px
iframe
max-width: 100%
.fitVid {
position: relative;
height: 0;
padding-top: 56.25%;
}
.fitVid iframe {
position: absolute;
z-index: 100;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
}
body {
max-width: 560px;
}
iframe {
max-width: 100%;
}
<h2>Video with fitVid class</h2>
<div class="fitVid">
<iframe width="560" height="315" src="//www.youtube.com/embed/kK0_OVn_uxA" frameborder="0" allowfullscreen></iframe>
</div>
<h2>Video with without the class</h2>
<iframe width="560" height="315" src="//www.youtube.com/embed/kK0_OVn_uxA" frameborder="0" allowfullscreen></iframe>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment