Skip to content

Instantly share code, notes, and snippets.

@Farmatique
Last active April 12, 2017 18:23
Show Gist options
  • Save Farmatique/d513be9f3268c7e5de9a9cb192dca412 to your computer and use it in GitHub Desktop.
Save Farmatique/d513be9f3268c7e5de9a9cb192dca412 to your computer and use it in GitHub Desktop.
Css padding hack for blocks with equal sizes
<div class="container">
<div class="container__wrapper">
<div class="container__content"></div>
</div>
</div>
.container {
width: 20%;
}
.container__wrapper {
overflow: hidden;
position: relative;
width: 100%;
padding-bottom: 100%; // пропорции блока определяются здесь
}
.container__content {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
background-color: #f00;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment