CSS 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-image and -webkit-mask-image for 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% and 85% stops.
- Strength: change
transparent to rgba(0,0,0,0.2) for softer fades.
Common pitfalls
- Forgetting the
-webkit-mask-image fallback in Safari.
- Expecting masks to work on elements with
overflow: hidden but 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?
1---2name: css-alpha-masking3description: Apply CSS alpha masking with linear-gradient for horizontal or vertical edge fades (mask-image and -webkit-mask-image). Use when asked for alpha masks, fade edges, or CSS mask gradients.4---5
6# CSS Alpha Masking Skill
7
8## Workflow
91. Confirm direction (horizontal or vertical) and fade stop percentages.
102. Provide the inline CSS snippet and any needed class usage.
113. Offer small tweaks only (direction, stop positions, colors).
12
13## Usage checklist
14- Apply the mask styles directly on the element or in a CSS class.
15- Always include both `mask-image` and `-webkit-mask-image` for Safari.
16- Ensure the element has visible content; masks reveal/hide alpha only.
17
18## Horizontal (left/right) fade
19```css
20/* Add this inline CSS to any element */
21mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
22-webkit-mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
23```
24
25## Vertical (top/bottom) fade
26```css
27/* Add this inline CSS to any element */
28mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
29-webkit-mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
30```
31
32## Customization knobs
33- Direction: `to right`, `to left`, `to bottom`, `to top`.
34- Fade depth: adjust `15%` and `85%` stops.
35- Strength: change `transparent` to `rgba(0,0,0,0.2)` for softer fades.
36
37## Common pitfalls
38- Forgetting the `-webkit-mask-image` fallback in Safari.
39- Expecting masks to work on elements with `overflow: hidden` but no visible content behind.
40
41## Questions to ask when specs are missing
42- Which direction should the fade go?
43- How wide should the fade edges be?
44- Is this for images, text, or a container background?