clamp() β€” RESPONSIVE WITH LIMITS


SYNTAX

clamp(MIN, PREFERRED, MAX)

πŸ‘‰ Think like this:

β€œValue should grow… but NOT go below MIN and NOT exceed MAX”


YOUR EXAMPLE

font-size: clamp(16px, 2vw, 32px);



calc() β€” DYNAMIC CALCULATION

SYNTAX

calc(expression)

You can do math inside CSS:

  • +
  • -
  • *
  • /


BASIC EXAMPLE

width: calc(100% - 50px);


πŸ” HOW IT CALCULATES

Let’s say:

  • Parent width = 1000px

πŸ‘‰ 100% = 1000px

Now:

1000px - 50px = 950px

πŸ‘‰ Final width = 950px


 Example 1: Layout spacing

.container {
  width: calc(100% - 40px);
}

πŸ‘‰ Leaves space for padding/margin


Example 2: Centering trick

.box {
  left: calc(50% - 100px);
}

πŸ‘‰ Moves element to center


Example 3: Equal columns

.col {
  width: calc(100% / 3);
}

πŸ‘‰ 3 equal columns