About css-alpha-masking
A design skill for adding directional alpha fades to CSS elements. It guides developers through mask settings, browser fallback, and small adjustments to fade direction and strength.
Key features
- 01Horizontal and vertical alpha fades
- 02Safari mask-image fallback
- 03Adjustable fade direction and stop positions
- 04Guidance on visible content and masks
Use cases
- 01Fade the edges of an image or text
- 02Apply a top-to-bottom container fade
- 03Tune fade width and softness
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ mengto/ skills --skill css-alpha-maskingAfter installing, type/css-alpha-maskingin Claude Code to confirm it loaded.
Bundled filesdemo/index.htmldemo/PROMPT.md
Details
From the project READMECSS Alpha Masking Skill
Workflow
- Confirm direction (horizontal or vertical) and fade stop percentages.
- Provide the inline CSS snippet and any needed class usage.
- Offer small tweaks only (direction, stop positions, colors).
Usage checklist
- Apply the mask styles directly on the element or in a CSS class.
- Always include both
mask-imageand-webkit-mask-imagefor Safari. - Ensure the element has visible content; masks reveal/hide alpha only.
Horizontal (left/right) fade
/* Add this inline CSS to any element */
mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
-webkit-mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
Vertical (top/bottom) fade
/* Add this inline CSS to any element */
mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
-webkit-mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
Customization knobs
- Direction:
to right,to left,to bottom,to top. - Fade depth: adjust
15%and85%stops. - Strength: change
transparenttorgba(0,0,0,0.2)for softer fades.
Common pitfalls
- Forgetting the
-webkit-mask-imagefallback in Safari. - Expecting masks to work on elements with
overflow: hiddenbut no visible content behind.
Questions to ask when specs are missing
- Which direction should the fade go?
- How wide should the fade edges be?
- Is this for images, text, or a container background?
Comments
Markdown supported