Last active
October 25, 2016 20:25
-
-
Save erming/437c45f72f7cf8195d22 to your computer and use it in GitHub Desktop.
Responsive square <div> with CSS only
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="square"> | |
<div class="square-content"> | |
Hello world! | |
</div> | |
</div> |
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
.square { | |
position: relative; | |
} | |
.square:before { | |
content: ""; | |
display: block; | |
padding-top: 100%; | |
} | |
.square-content { | |
position: absolute; | |
top: 0; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment