CSS MASK / FADE EDGE GENERATOR
Fade out the edges of an image or block with a mask-image gradient and copy the CSS.
In short
Fade out the edges of an image or block with a CSS mask-image gradient — pick which edges fade (top, bottom, left, right, or all) and how far, on a live preview, then copy the CSS. No image editing needed, runs entirely in your browser.
.fade-edge {
-webkit-mask-image: linear-gradient(to bottom, black 0%, black 70%, transparent 100%);
mask-image: linear-gradient(to bottom, black 0%, black 70%, transparent 100%);
}How to fade an element's edges
- 1
Choose which edge (or edges) should fade out.
- 2
Adjust the fade size on the live preview.
- 3
Copy the generated CSS.
- 4
Apply the .fade-edge class to any image or block element.
Questions
- How does mask-image fade an edge without cropping the element?
- mask-image uses a gradient's alpha channel to control an element's opacity pixel by pixel — black areas of the gradient stay fully visible, transparent areas become fully invisible, and anything in between blends smoothly. Unlike clip-path, which cuts a hard edge, a mask gradient fades it gradually.
- Why does the CSS include both -webkit-mask-image and mask-image?
- mask-image is well supported in current browsers, but Safari has historically required the -webkit- prefixed property for reliable rendering. Including both covers the widest range of browsers without any extra JavaScript.
- How is the 'fade all edges' mode different from the single-edge modes?
- The single-edge and opposite-edge modes use a linear-gradient along one axis. Fade all edges instead uses a radial-gradient from the center outward, so all four sides — and the corners — fade together into a soft vignette rather than fading independently.
- Can I use this on a background image instead of a foreground image?
- mask-image only affects the element it's applied to, including its background. Apply the same mask-image/-webkit-mask-image rules to a div with a background-image instead of an <img>, and the background will fade the same way.
- Does this tool upload my image?
- This generator doesn't take an image upload at all — it demonstrates the mask on a sample gradient block so you can copy the CSS and apply it to your own image or element locally, with nothing sent to a server.
Related tools
- CSS Ticket & Coupon Shape GeneratorGenerate CSS for a ticket or coupon shape with notched sides, top and bottom, or cut corners and a dashed perforation line, using a transparent mask.
- CSS Ribbon GeneratorGenerate CSS and HTML for a diagonal corner sash or a banner ribbon with a swallowtail, arrow, or flat tail, with custom text, colors, and shadow.
- CSS Speech Bubble GeneratorBuild a chat-style speech bubble with a border-trick tail on any side, and copy the CSS.
- CSS Squircle GeneratorBuild an iOS-style continuous-curve squircle from a superellipse formula rendered as a clip-path polygon, and copy the CSS.
- CSS Animated Glowing Border GeneratorBuild a rotating conic-gradient border that chases around a card, with adjustable speed, thickness, and glow blur.
- CSS Link Underline Effects GeneratorBrowse a gallery of 10 hover underline effects for links — slide in, center out, double line, dot grow, and more.
- CSS Gradient Border GeneratorBuild a rounded gradient border with 2-5 color stops using the padding-box/border-box trick, and copy the CSS.
- CSS Button Hover Effects GeneratorBrowse a gallery of button hover effects — sweep, fill, shine, ripple, lift, and outline grow — and copy the CSS.
Updated