CSS | calc() Function
The calc() function is an inbuilt function in CSS which is used to perform calculations based on CSS property.
Syntax:
calc( Expression )
Parameters: This function accepts single parameter Expression which is mandatory. This parameter contains mathematical expression which need to implement. The operators used by this parameters are: +, -, *, /
Below program illustrates the calc() function in CSS:
Program:
<!DOCTYPE html> <html> <head> <title>calc function</title> <style> .geeks { position: absolute; left: 50px; width: calc(100% - 20%); height:calc(500px - 300px); background-color: green; padding-top:30px; text-align: center; } .gfg { font-size:40px; font-weight:bold; color:white } h1 { color:white; } </style> </head> <body> <div class = "geeks"> <div class = "gfg">GeeksforGeeks</div> <h1>The calc() Function</h1> </div> </body> </html> |
Output:

Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- D3.js | d3.max() function
- p5.js | hex() function
- p5.js | str() function
- PHP | pi( ) Function
- p5.js | box() Function
- p5.js | arc() Function
- PHP | each() Function
- p5.js | nf() Function
- PHP | pow( ) Function
- p5.js | min() function
- PHP | key() Function
- p5.js | hue() function
- D3.js | d3.hsl() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



