Created
April 26, 2023 15:49
-
-
Save amilabandara/5b8db35c23edcfd0609bb6905e0adcfa to your computer and use it in GitHub Desktop.
Responsive Aspect ration images
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
.ratio-image { | |
position: relative; | |
height: 0; | |
padding-bottom: 100%; | |
img { | |
max-width: 100%; | |
position: absolute; | |
top: 0; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
width: 100%; | |
height: 100%; | |
object-fit: cover; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment