Horje
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

  • Arithmetic Operations: calc supports basic arithmetic operations like addition, subtraction, multiplication, and division.
  • Units: You can perform calculations with different units (e.g., pixels, em, vmin).
  • Dynamic Sizing: Useful for creating responsive designs where values depend on dynamic factors.
  • Browser Support: Widely supported in modern browsers.



Reffered: https://www.geeksforgeeks.org


Web Technologies

Related
What is the use of the HTML datalist Element ? What is the use of the HTML datalist Element ?
How to apply the Clearfix Hack in CSS ? How to apply the Clearfix Hack in CSS ?
How to make Element transparent in CSS ? How to make Element transparent in CSS ?
What is the purpose of using the <meta charset="UTF-8"> Tag ? What is the purpose of using the <meta charset="UTF-8"> Tag ?
What is the importance of WAI-ARIA in HTML ? What is the importance of WAI-ARIA in HTML ?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
11