Skip to content

Instantly share code, notes, and snippets.

@elikem
Created May 28, 2014 22:09
Show Gist options
  • Select an option

  • Save elikem/33f9d863e76cab8bc24e to your computer and use it in GitHub Desktop.

Select an option

Save elikem/33f9d863e76cab8bc24e to your computer and use it in GitHub Desktop.
Maintain Aspect Ratio with CSS
<div style="width: 100%; position: relative; padding-bottom: 20%;">
<div style="position: absolute; left: 0; top: 0; right: 0; bottom: 0;">
this content will have a constant aspect ratio that varies based on the width.
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment