freecoding.school100% FREE · NO SIGNUP
Neon DistrictISSUE #18 of 50

object-position · framing

PrismaVSJank the Janitor
Prisma saysobject-position frames which part of an over-cropped image stays visible.

When object-fit:cover crops an image, object-position chooses what stays in view (default center). object-position: top keeps heads in portrait thumbnails; percentages and lengths give precise control. The background-position analog for media.

Power-ups you unlock

Jank the Janitor attacks — common mistakes

Boss battleCrop a tall portrait to a square but keep the top (face) visible with object-position:top.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>img{width:120px;height:120px;object-fit:cover;object-position:top;border-radius:8px}</style></head><body style="background:#06040d;padding:20px"><img src="https://via.placeholder.com/120x300" alt=""></body></html>
▶ Open the interactive comic issue
‹ Object-Fit · Sizing MediaAspect-Ratio · Holding Shape ›