Pillar 2 · Level 2 Visual Aesthetics

Framing, Masks & Reflection Labs

How you frame an image defines how users experience it. Here, we tackle the art of image framing: locking down responsive aspect ratios, anchoring focal points to protect portraits from bad mobile crops, and layering alpha gradient masks for seamless visual transitions.

X:75% Y:25%
object-position: var(--fx) var(--fy)
Live Preview
16 : 9
object-fit: cover
Live Preview
MASK_ALPHA
mask-image: linear-gradient()
Live Preview
PRODUCT_3D
Live Preview
<picture> AVIF (-75%)
srcset="800w, 1600w" sizes
Live Preview

Eliminating Layout Shift (CLS) and Preserving Focal Centers

Proper media framing requires two principles: reserving layout geometry before images download (aspect-ratio), and guaranteeing that the primary subject remains in frame across diverse responsive aspect ratios (object-position focal pinning).

📖 Read the Complete Tutorial: Creative Media Framing, Masks & Reflections Guide →

Frequently Asked Questions

How does object-position eliminate awkward cropping?

Default object-fit: cover crops to the exact center (50% 50%). For tall portraits or wide landscapes, faces or subjects get chopped off. Specifying object-position coordinates locks the crop anchor directly to the subject coordinates.

Does -webkit-box-reflect require duplicated HTML markup?

No. The -webkit-box-reflect property instructs the GPU paint engine to mirror the rendered element downwards, pairing it with a linear alpha gradient mask to produce seamless Apple-style hardware product showcases.

How do I mask an image into a custom shape using CSS mask-image?

Use mask-image: url("shape.svg"); -webkit-mask-image: url("shape.svg"); with mask-size: cover; and mask-repeat: no-repeat;. The alpha transparency of the SVG file cuts the image into the custom silhouette.

What is the difference between CSS clip-path and mask-image?

clip-path creates hard vector polygon boundaries with 100% on/off clipping. mask-image supports 8-bit alpha channels, allowing feathered edges, gradient dissolves, and textured grunge borders.

Why is my CSS mask-image not displaying in Chrome or Safari?

WebKit and Chromium browsers require the -webkit-mask-image vendor prefix. Always declare both -webkit-mask-image and mask-image in your stylesheet for universal cross-browser support.

How do I create an animated image reveal mask in CSS?

Animate mask-position or mask-size using CSS keyframes, or animate an SVG path inside the mask element to create organic paint-brush or liquid wipe transitions across the photo.

Can I use CSS linear gradients as image masks?

Yes. Setting mask-image: linear-gradient(to bottom, black 60%, transparent 100%); fades the bottom of an image seamlessly into your page background without using PNG overlays.