CSS sin(), cos(), tan() Demo - Online Animated Trig
Use trigonometric functions in CSS to create circular animations and layouts without JavaScript. See the code.
UD5 Toolkit
Interactive playground for CSS mathematical functions — explore powers, square roots, hypotenuse calculations & their trigonometric connections
Returns baseexponent. Ideal for fluid type scales, exponential spacing, and dynamic sizing systems.
Returns the square root. Perfect for calculating diagonal lengths, normalizing values, and area-to-side conversions.
Returns √(a² + b² + …). The Pythagorean theorem in CSS — crucial for distance, shadow offsets, and trigonometric layouts.
:root {
--base: 2;
--exponent: 3;
}
.box {
width: calc(pow(var(--base), var(--exponent)) * 15px);
height: calc(pow(var(--base), var(--exponent)) * 15px);
/* = 8 × 15px = 120px */
}
:root {
--area: 64;
}
.side {
width: calc(sqrt(var(--area)) * 10px);
height: calc(sqrt(var(--area)) * 10px);
/* = 8 × 10px = 80px */
}
:root {
--offset-x: 30;
--offset-y: 40;
}
.shadow-distance {
--dist: hypot(var(--offset-x), var(--offset-y));
box-shadow: 0 0 calc(var(--dist) * 1px) rgba(0,0,0,0.25);
/* = 50px blur radius */
}
/* Also useful for: */
.diagonal-length {
width: calc(hypot(300, 400) * 1px); /* = 500px */
}
pow(base, exponent) calculates base raised to the exponent power. sqrt(value) returns the square root. hypot(a, b, …) computes the square root of the sum of squares — essentially the Pythagorean hypotenuse. They return numeric values usable anywhere CSS accepts numbers (calc(), custom properties, etc.).sin(), cos(), and tan() handle angular trigonometry, hypot() directly implements the Pythagorean theorem (c² = a² + b²), which is foundational to trigonometry. Together, they enable complex geometric calculations in pure CSS — for example, hypot() gives you the hypotenuse, while atan2(y, x) gives you the angle. They complement each other for positioning, rotation, and distance calculations.@supports queries or pre-calculate values with a CSS preprocessor. Always test with @supports (width: calc(pow(2, 3) * 1px)) before relying on these functions.pow(1.25, var(--step))), exponential spacing systems, dynamic animation curves, and non-linear size relationships. For example, you can create a type scale where each heading is 1.25× the previous: font-size: calc(pow(1.25, var(--level)) * 1rem).sqrt() when you need to normalize values, calculate diagonal lengths of elements (width² + height² under a square root), convert area to side length, or implement inverse-square law effects (like realistic lighting/shadows where intensity falls with distance²). It's also handy for creating circular progress indicators and radial layouts.hypot() is more concise than sqrt(pow(a, 2) + pow(b, 2)), less error-prone, and more readable. It also handles edge cases better — it's numerically stable for very large or very small values, avoiding overflow/underflow that can occur when squaring numbers manually. Plus, it accepts multiple arguments: hypot(3, 4, 5) computes √(3²+4²+5²) = √50 ≈ 7.07.pow(): The base must be non-negative (≥ 0), though the exponent can be any real number. sqrt(): The input must be non-negative (≥ 0); negative values are invalid. hypot(): Arguments can be any real numbers (positive, negative, or zero) — the result is always non-negative since it's the square root of a sum of squares. Always validate inputs when using CSS custom properties with these functions.@supports feature queries:@supports (width: calc(hypot(3, 4) * 1px)) { /* modern code */ }--distance: 50px; /* fallback */
--distance: calc(hypot(var(--x), var(--y)) * 1px);calc(), clamp(), min(), and max(). Example: font-size: clamp(1rem, calc(sqrt(var(--viewport-width)) * 0.5rem), 4rem); You can also nest them: pow(sqrt(var(--x)), 3) = x1.5. This composability is what makes CSS math functions so powerful for creating flexible, responsive designs without JavaScript.Use trigonometric functions in CSS to create circular animations and layouts without JavaScript. See the code.
Full-featured scientific calculator with trigonometric, logarithmic, and exponential functions. Clean interface and keyboard support. No installation required.
Compute sine, cosine, tangent, and their inverses. Input degrees or radians to instantly get exact values or decimal approximations for any angle.
Design a layout where nested grids share track sizes with their parent via subgrid. Copy the complete CSS.
Create a pure CSS scroll progress indicator using animation‑timeline: scroll(). No JavaScript. Copy the complete code.
Paste your CSS and see warnings for properties that have limited browser support. Links to CanIUse. Modernize safely.
Limit browser gestures on an element: pan‑x, pinch‑zoom, manipulation. Draw on a canvas to test. Mobile dev helper.
Create complex linear gradients with any number of color stops, exact angles, and length units. Live preview and CSS code.
Style underlines, overlines, and strike-throughs with colors, wavy styles, and thickness. Modern CSS text‑decoration.
Generate a random HTML/CSS card with different box model properties. Inspect and guess the size. For learners.
Design a button or card that glows on hover. Adjust shadow color, spread, and transition. Copy the CSS. Rich UI.
Create a realistic letterpress (debossed) text effect using CSS text‑shadow and background. Adjust depth and light direction. Copy code.
Paste your CSS and sort the properties of each rule alphabetically or by concentric groups. Keep your stylesheets consistent without a build step.
Generate a subtle noise/grain texture as a CSS background pattern. Adjust opacity and size. For that film look.
Create a customizable checkerboard or grid background using pure CSS gradients. Adjust cell size and colors. Copy the code.
Upload two images and apply CSS blend modes (multiply, screen, overlay, etc.). See the result and copy the filter CSS. Pure frontend.
Add print styles like removing backgrounds, adding page breaks, setting margins. See print preview instantly.
Create a pure CSS countdown timer with a flipping number effect. Adjust duration and style. No JavaScript needed for display.
Paste HTML/CSS snippets or enter properties to test how z‑index and stacking contexts interact. Real‑time example.
Create a glowing or rotating border animation around an element. Copy the CSS keyframes. Pure CSS magic.
Create a custom HTML/CSS progress bar with percentage, colors, and animation. Copy the code. Modern UI element.
Design a realistic neon sign text with multiple layers of glow. Copy the CSS and HTML. Perfect for headers.
A replica of the famous Flexbox Froggy game: solve alignment puzzles by writing CSS. Progress saved locally. Fun frontend learning.
Fetch a website's CSS and extract :root custom properties (‑‑color) to reveal its design token palette. For learning and inspiration.
Select a ratio (1.25, 1.333, 1.5) and a base size to generate a full typographic scale for h1‑h6. Copy CSS variables.
Recreate the target CSS linear gradient by adjusting stops and colors. A unique game for front‑end developers to master gradients.
Browse and search all Font Awesome 6 icons with preview, class name, and unicode. Copy the HTML snippet. Perfect for web developers.
Create text with a gradient fill using CSS background-clip. Configure colors and direction. Copy the code. Works in modern browsers.
A complete, searchable list of all 140+ named HTML/CSS colors with their hex codes and color previews. Click to copy code. Essential web reference.
Visually experiment with Flexbox container and item properties. See the layout update in real time and copy the CSS. Learn by doing, fully interactive.