Skip to content

Instantly share code, notes, and snippets.

@marioblas
Forked from ayozebarrera/ratio.css
Last active August 29, 2015 14:10
Show Gist options
  • Save marioblas/7896484c74deb07296b0 to your computer and use it in GitHub Desktop.
Save marioblas/7896484c74deb07296b0 to your computer and use it in GitHub Desktop.
CSS - Aspect ratio 16:9
.aspect-ratio {
display: block;
height: 0; /* we have padding-bottom instead height (content + padding - bottom) */
padding-bottom: 56.25%; /* 16:9 ratio -> (9 ÷ 16) × 100 = 56.25 */
overflow: hidden;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment