Skip to content

Instantly share code, notes, and snippets.

@SBoudrias
Created September 23, 2012 03:16
Show Gist options
  • Save SBoudrias/3768707 to your computer and use it in GitHub Desktop.
Save SBoudrias/3768707 to your computer and use it in GitHub Desktop.
Keeping element ratio
/**
* Keeping element ratio
*/
.container {
background: red;
width: 100%;
padding-bottom: 60%;
position: relative;
}
.ratio-keep {
background: lime;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
<div class="container">
<div class="ratio-keep"></div>
</div>
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment