Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Think of the joyous Indian festival of Holi: clouds of vibrant dry gulal powders—turquoise, saffron, magenta, and emerald—swirling together in the warm spring breeze to form organic, dreamy color gradients. Or think of school art students using strips of masking tape to create feathered gradient stencils on handmade greeting cards.
In this chapter, we will master modern cutting-edge CSS visual design:
conic-gradient(): Crafting circular pie charts, radar sweeps, and chromatic color wheels.mask-image): Unlocking feathered, semi-transparent fade-outs that go far beyond rigid clip-paths!While linear-gradient moves along a straight directional line and radial-gradient radiates outward from a center point, conic-gradient() rotates colors around a central pivot point like the sweep of a radar beam or the hands of a clock:
+-------------------------------------------------------------------------+
| THE THREE GRADIENT GEOMETRIES |
+-------------------------------------------------------------------------+
1. LINEAR GRADIENT 2. RADIAL GRADIENT 3. CONIC GRADIENT
[===> Straight line ===>] (( ( Concentric ) )) \ Rotates /
Left to Right, or Diagonal Radiates from center \ around /
\ center /With a single line of conic-gradient, you can build an authentic circular pie chart or test score donut without SVG or JavaScript:
Modern tech companies (like Stripe and Apple) frequently feature soft, organic "Aurora / Mesh" gradient backdrops.
In pure CSS, you achieve this by layering multiple radial gradients or positioning blurred, floating colored divs with heavy filters:
mask-image vs clip-pathA crucial distinction in advanced CSS is understanding when to use clip-path and when to use mask-image:
+-------------------------------------------------------------------------+
| CLIP-PATH (BINARY) VS MASK-IMAGE (ALPHA) |
+-------------------------------------------------------------------------+
1. clip-path:
- Binary: A pixel is either 100% VISIBLE or 100% CLIPPED OFF.
- Hard, razor-sharp vector edges.
- Cannot do gradual, misty, feathered semi-transparencies.
2. mask-image:
- Luminance & Alpha: Pixels can be 10%, 40%, 80% translucent!
- Allows gentle, feathered gradient fades into nothingness.
- Ideal for scroll fades, vignettes, and image texture blending.Have you ever seen an app where a horizontal list of badges smoothly fades into transparency at the left and right edges, hinting to the user that more content lies beyond?
This is accomplished in one line of CSS using mask-image:
-webkit-mask-image with mask-image for complete cross-browser iOS and macOS compatibility.By using repeating-conic-gradient(), you can generate geometric rays and retro sunburst backdrops with pure mathematical code:
| Practice | Bad Approach | Good Approach | Why It Matters |
|---|---|---|---|
| Mask Prefixes | Writing only mask-image | Always including -webkit-mask-image first | Safari does not support the un-prefixed mask-image property. |
| Fade Transitions | Placing semi-transparent white PNG boxes on top of scrollbars | Using mask-image: linear-gradient(...) | Masking affects the actual rendered pixels regardless of underlying background color. |
| Mesh Performance | Animating 10 massive filter: blur(80px) elements on phones | Using static multi-radial background gradients | Heavy runtime blur recalculations drain mobile batteries; pre-blended gradients render on the GPU instantly. |
| Pie Chart Gaps | Leaving overlapping color stops like red 0% 50%, blue 40% 100% | Using clean abrupt stops: red 0% 50%, blue 50% 100% | Ensures crisp, razor-sharp sector boundaries without fuzzy color bleeds. |
conic-gradient(): Colors sweep around a center angle. Ideal for pie charts, donut gauges, and chromatic sweeps.conic-gradient to a circle, then overlay a smaller inner circle (or pseudo-element) in the center.mask-image: Uses an alpha or luminance gradient to feather edges into transparency.-webkit-mask-image alongside mask-image.radial-gradient() declarations at varied $(X, Y)$ focal percentages.conic-gradient() differ from radial-gradient() in CSS?mask-image provides which clip-path cannot achieve?mask-image to function properly across Apple Safari and iOS devices?conic-gradient(#10b981 0% 70%, #e2e8f0 70% 100%), what proportion of the circle is filled with green?Build an interactive student examination result badge featuring a multi-layered Aurora mesh background, a single-element pure CSS conic-gradient progress donut, and feathered edge masking.
conic-gradient(#10b981 0% 92%, rgba(255,255,255,0.15) 92% 100%).-webkit-mask-image: linear-gradient(to right, black 80%, transparent 100%);.Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Test your understanding of this lesson with 5 questions. Each question has one correct answer.