Created
September 8, 2020 23:00
-
-
Save Ifmr24/650eeed5bb3dd587e1e8da4572bf76e5 to your computer and use it in GitHub Desktop.
aspect ratio css
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
.post { | |
width:320px; | |
position: relative; | |
background-color: #dbdbdb; | |
} | |
.post::after { | |
display: block; | |
content: ""; | |
/* 1:1 */ | |
padding-bottom: 100%; | |
/* 16:9 = 56.25% */ | |
} | |
.post img { | |
width: 100%; | |
height: 100%; | |
vertical-align: top; | |
object-fit: cover; | |
position: absolute; | |
left: 0; | |
top: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment