TIL how to Make a Square with CSS with aspect-ratio
POSTED ON:
TAGS: css
If you want to make a square without having to mess around too much with width and height, you can style your div [or span as the case may be] by setting a background color, the width you need, and then an aspect-ratio with equal figures. The first figure is for the top and bottom dimension, the second is for left and right.
.square {
background: green;
width: 25rem;
aspect-ratio: 1/1;
}
Via CSS Cheat Sheet – 10 Tricks to Improve Your Next Coding Project
Related TILs
Tagged: css