Skip to content

Instantly share code, notes, and snippets.

@dsignr
Created June 28, 2014 09:34
Show Gist options
  • Save dsignr/742cb2fce105cdfe809a to your computer and use it in GitHub Desktop.
Save dsignr/742cb2fce105cdfe809a to your computer and use it in GitHub Desktop.
Responsive fluid squares
/*-- credits: http://jsfiddle.net/josedvq/38Tnx/ --*/
.square-box{
position: relative;
width: 50%;
overflow: hidden;
background: #4679BD;
}
.square-box:before{
content: "";
display: block;
padding-top: 100%;
}
.square-content{
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
color: white;
}
.square-content div {
display: table;
width: 100%;
height: 100%;
}
.square-content span {
display: table-cell;
text-align: center;
vertical-align: middle;
color: white
}
<!-- credits: http://jsfiddle.net/josedvq/38Tnx/ -->
<div class='square-box'>
<div class='square-content'><div><span>Aspect ratio 1:1</span></div></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment