Skip to content

Instantly share code, notes, and snippets.

@a-double
Created March 11, 2015 21:31
Show Gist options
  • Select an option

  • Save a-double/64686f2c37a36659811f to your computer and use it in GitHub Desktop.

Select an option

Save a-double/64686f2c37a36659811f to your computer and use it in GitHub Desktop.
Flexible media embeds
/* https://github.com/suitcss/components-flex-embed/blob/master/lib/flex-embed.css */
.flex-embed {
display: block;
position: relative;
overflow: hidden;
}
.flex-embed-inner {
display: block;
width: 100%;
padding-bottom: 56.26%; /* or whatever ratio, this is 16x9 */
}
.flex-embed iframe, .flex-embed object, .flex-embed embed {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
}
<div class="flex-embed">
<div class="flex-embed-inner"></div>
<!-- iframe, embed, object, etc. -->
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment