Open In App

How to use the “calc” Function in CSS ?

The calc function in CSS allows you to perform calculations within property values. It is useful for dynamically adjusting sizes, margins, paddings, and other numeric values based on specific calculations.

Note: The calc function can be used with various arithmetic operations.

Syntax

.container {
width: calc(100% - 20px);
padding: calc(2em + 10px);
font-size: calc(16px + 2vmin);
}

Features

Article Tags :