About Lesson
. calc() Function in CSS:
The calc() function is used to perform calculations in CSS. It allows you to combine different units (like percentages, pixels, em, etc.) and perform arithmetic operations (+, -, *, /) to create dynamic layouts.
Syntax:
CSS
width: calc(100% - 50px);
Example:
You might use calc() to set the width of an element based on the viewport size, but subtract some fixed value like a sidebar width:
CSS
.main {
width: calc(100% - 200px); /* 100% width minus 200px */
}