40+ CSS calc() Examples (Page 2)
Examples

CSS Blockquote with Gradient Drop Cap
A unique drop cap is created with modern CSS techniques - its complex background is generated by layering linear-gradient and repeating-conic-gradient, while its responsive size is managed by calc().
See the Pen CSS Blockquote with Gradient Drop Cap.

Scalable CSS Radial Gradient Pattern
A pure CSS pattern created by overlaying five radial-gradient declarations on a single element. The main feature is that all ring sizes and their count depend on a couple of CSS variables, making the pattern fully scalable using calc().
See the Pen Scalable CSS Radial Gradient Pattern.

Fancy Corner Decoration for Images
A border effect for an <img> tag - the size of the decorative edge, created with repeating-conic-gradient and -webkit-mask, is dynamically calculated via a complex calc() function controlled by CSS variables.
See the Pen Fancy Corner Decoration for Images.

Interactive Card Glow Effect
A modular React card component where a single pointermove listener updates CSS variables, powering a customizable, multi-layer glow and spotlight effect.
See the Pen Interactive Card Glow Effect.

Circular Battery Meter
An SVG-based battery meter where the fill level is a clever trick - JavaScript updates a CSS variable that drives a calc() function to animate the stroke-dashoffset of several <circle> elements simultaneously, creating a multi-layered visual effect.
See the Pen Circular Battery Meter.

Digital-Analog Dial Clock
A digital-analog clock hybrid where JavaScript’s setInterval only updates a single CSS variable - --dRotate, while all the complex rotation and counter-rotation of the dials and numbers is handled by pure CSS transform.
See the Pen Digital-Analog Dial Clock.

Multi-Card Spotlight Effect
An interactive 3D card effect where JavaScript tracks pointermove, calculates the relative cursor position, and passes it to --ratio-x and --ratio-y CSS variables, while CSS uses calc() to drive rotateX and rotateY.
See the Pen Multi-Card Spotlight Effect.

CSS Knob Widget with Range Slider
A demonstration of the power of CSS and Sass - the knob is a standard range slider where the thumb is styled as a knob, and its transform: rotate is calculated based on the input’s value via CSS variables updated by JS.
See the Pen CSS Knob Widget with Range Slider.

Range Slider with Value and Ruler
An unconventional use of datalist to create a custom ruler scale under the slider, where tick marks are styled using box-shadow and linear-gradient, and their visibility is controlled by CSS variables within media queries.
See the Pen Range Slider with Value and Ruler.

CSS Triangles with pow() and sqrt()
A demonstration of creating perfectly equilateral CSS triangles using the native pow() and sqrt() mathematical functions inside calc(). This showcases how to achieve geometric precision without preprocessors, relying solely on modern CSS.
See the Pen CSS Triangles with pow() and sqrt().
Pure CSS Responsive Hex Grid
An adaptive hexagonal grid without media queries, built on Container Queries, where the column count and the position of each element are calculated in CSS via complex calc() functions. The code demonstrates progressive enhancement - with a fallback to @property and a tan(atan2()) math trick to emulate division in older browsers.
See the Pen Pure CSS Responsive Hex Grid.
Wheel Timeline. Pure CSS
An interactive radial carousel in pure CSS, where element positioning in a circle is calculated via calc(). State management is handled without JS using the “radio button hack” and the :has() pseudo-class, which triggers rotation animations and sequential content appearance.
See the Pen Wheel Timeline. Pure CSS.
Hover/Focus Effect For Flat Burron
A “slicing” fill effect created with two pseudo-elements - rotated rectangles that slide in from opposite sides on hover. The animation state is controlled by the --p CSS variable, which changes from 0 to 1, triggering the transform of the pseudo-elements via calc() to create a complex geometric transition.
See the Pen Hover/Focus Effect For Flat Burron.