Skip to content

Instantly share code, notes, and snippets.

@jxnblk
Created October 19, 2013 01:37
Show Gist options
  • Save jxnblk/7050720 to your computer and use it in GitHub Desktop.
Save jxnblk/7050720 to your computer and use it in GitHub Desktop.
// Aspect ratio classes are useful for things like fluid-width background images
// These fill the width of parent elements
.aspect-square {
width: 100%;
height: 0;
padding-bottom: 100%;
}
.aspect-4o3 {
width: 100%;
height: 0;
padding-bottom: 75%;
}
.aspect-16o9 {
width: 100%;
height: 0;
padding-bottom: 56.25%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment