Skip to content

Instantly share code, notes, and snippets.

@dededey
Created September 8, 2015 09:33
Show Gist options
  • Save dededey/de1e5ba95624c5cadbdd to your computer and use it in GitHub Desktop.
Save dededey/de1e5ba95624c5cadbdd to your computer and use it in GitHub Desktop.
CSS
.box{
position: relative;
width: 50%; /* desired width */
}
.box:before{
content: "";
display: block;
padding-top: 100%; /* initial ratio of 1:1*/
}
<div class='box'>
<div class='content'>Aspect ratio of 1:1</div>
</div>
We need two block elements to achieve the desired behaviour. No images, no Javascript.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment