CSS

CSS Overview Selectors Declarations Rule Sets Comments Reset/Normalize Origin Importance Order Specificity Inheritance Cascade Layers Inline Styles Internal Styles External Styles @import Absolute Units Relative Units Dynamic Viewport Angle Units Time Units Frequency Units: Resolution Units Keywords Color Formats Color Functions & Spaces Background Color Background Image Background Repeat Background Position Background Size Background Attachment Background Shorthand Multiple Backgrounds Linear Gradients Radial Gradients Conic Gradients Font Family Font Size Font Weight Font Style Line Height Text Align Text Decoration Text Transform Letter Spacing Word Spacing Text Shadow Text Wrap Variable Fonts Content Box Padding Box Border Box Margin Box Box Sizing Property Margin Padding Border Outline Box Shadow Block Display Inline Display Inline Block Display Static Position Relative Position Absolute Position Fixed Position Sticky Position Top Element Position Right Element Position Bottom Element Position Left Element Position Z Index Flexbox Box Layout Display Flex Flex Direction Flex Wrap Justify Content Align Items Align Content Gap, Row Gap & Column Gap Flex Grow Flex Shrink Flex Basis Flex Shorthand Order Property Align Self Practical Applications CSS Grid Layout Grid Display Grid Template Columns Grid Template Rows Grid Template Areas Justify Items Grid Auto Columns Justify Self Nested Grids Responsive Web Design Min Width Max Width Orientation Logical Operators Pointer Hover Prefers Color Scheme Fluid Images Flexible Typography Viewport Width Advanced CSS Features Defining variables Using variables Scope & Inheritance of CSS Variables Property Value Fallback Practical Applications :Hover :Active :Focus :Focus Visible :Visited :Link :First Child :Last Child :Nth Child :Nth of Type :Empty :Checked :Disabled :Enabled :Valid :Invalid :Required :Has :Not :Is :Where ::Before Pseudo Element ::After Pseudo Element ::First Letter ::First Line ::Selection ::Marker CSS 2D Transformations CSS 3D Transformations Transform Origin Transform Style Backface Visibility Transition Property Transition Duration Transition Timing Function Transition Delay Transition Shorthand Ease Timing Function Linear Timing Function Ease In Timing Function Ease Out Timing Function Ease In Out Timing Function Cubic Bezier Function Animations (@keyframes) Defining @keyframes Animation Name CSS Animation Duration Animation Timing Function CSS Animation Delay CSS Animation Iteration Count Animations Direction CSS Animation Fill Mode CSS Animation Play State CSS Filter Blur CSS Filter Brightness CSS Filter Contrast() CSS Drop Shadow CSS Grayscale CSS Hue Rotate CSS Invert CSS Opacity CSS Saturate CSS Sepia Mix Blend Mode Background Blend Mode Object Fit & Object Position Scroll Snap Type Scroll Snap Align Scroll Padding Scroll Margin Scroll Triggered Animations JS Variables

Conic Gradients


Conic gradients are a powerful CSS feature that allows you to create gradients with color transitions rotated around a center point, similar to the sweep of a radar screen or a pie chart. Unlike linear and radial gradients, the colors in a conic gradient are not defined along a straight line or from a central point outwards, but rather in a circular fashion. This makes them ideal for creating circular progress bars, color wheels, and other dynamic, circular designs.


Example 1: Simple Two-Color Conic Gradient

.conic-gradient-1 {
  width: 200px;
  height: 200px;
  /* Creates a simple conic gradient transitioning from blue to yellow */
  background: conic-gradient(blue, yellow);
}

Explanation: This code creates a simple conic gradient within a div. The gradient starts with blue at the top (0 degrees), transitions smoothly to yellow as it progresses clockwise, and completes the circle.


Example 2: Conic Gradient with Three Colors

.conic-gradient-2 {
  width: 200px;
  height: 200px;
  /* A conic gradient with three specified color stops */
  background: conic-gradient(red, orange, yellow);
}

Explanation: This example demonstrates a conic gradient with three colors. Red, orange, and yellow are distributed evenly around the center point, creating a smooth, circular transition between them.


Example 3: Specifying Color Stop Angles

.conic-gradient-3 {
  width: 200px;
  height: 200px;
  /* Conic gradient with precise angle control for each color */
  background: conic-gradient(from 45deg, purple 0deg, lightblue 90deg, green 180deg);
}

Explanation: Here, we define specific angles for our color stops and a starting angle for the gradient. The from 45deg sets the gradient's starting point, with purple at 0 degrees, transitioning to light blue at 90 degrees, and then to green at 180 degrees.


Example 4: Creating a Pie Chart

.pie-chart {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  /* Using hard color stops to create distinct pie chart segments */
  background: conic-gradient(
    gold 0% 25%,        /* First segment: 25% */
    dodgerblue 25% 70%, /* Second segment: 45% */
    deeppink 70% 100%   /* Third segment: 30% */
  );
}

Explanation: This code creates a pie chart effect by using hard color stops. gold occupies the first 25% of the circle, dodgerblue takes the space between 25% and 70%, and deeppink fills the remaining portion, resulting in sharp, distinct segments.


Example 5: Repeating Conic Gradient

.repeating-conic {
  width: 200px;
  height: 200px;
  /* A repeating pattern created with a repeating-conic-gradient */
  background: repeating-conic-gradient(
    #f06 0deg 10deg,
    #fff 10deg 20deg
  );
}

Explanation: The repeating-conic-gradient() function creates a pattern that repeats around the center. In this case, a 10-degree pink segment is followed by a 10-degree white segment, and this pattern repeats to fill the entire circle.


Example 6: Positioning the Gradient's Center

.positioned-conic {
  width: 200px;
  height: 200px;
  /* Positioning the center of the conic gradient to the top left */
  background: conic-gradient(at top left, navy, cornflowerblue);
}

Explanation: This example utilizes the at keyword to move the center of the conic gradient. By setting it to top left, the gradient's origin is shifted from the center of the element to its top-left corner.


Example 7: Checkerboard Pattern

.checkerboard {
  width: 200px;
  height: 200px;
  /* Creating a checkerboard pattern using a conic gradient */
  background: conic-gradient(
    #ccc 0% 25%,
    #eee 25% 50%,
    #ccc 50% 75%,
    #eee 75% 100%
  );
  background-size: 50% 50%;
}

Explanation: This code generates a four-quadrant conic gradient. By setting the background-size to 50% 50%, the pattern is repeated, creating a simple and effective checkerboard effect within the element.