Created
September 8, 2015 09:33
-
-
Save dededey/de1e5ba95624c5cadbdd to your computer and use it in GitHub Desktop.
box with 1:1 ratio source: http://www.mademyday.de/css-height-equals-width-with-pure-css.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CSS | |
.box{ | |
position: relative; | |
width: 50%; /* desired width */ | |
} | |
.box:before{ | |
content: ""; | |
display: block; | |
padding-top: 100%; /* initial ratio of 1:1*/ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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