25 CSS Hacks Every Developer Should Know

Object fit for images

Problem: ensuring images fit within their containers without distortion.

Solution: use `object-fit`.

.fit-image {
  width: 100%;
  height: 200px;
  object-fit: cover; /* or contain, fill, etc. */
}