186 of 313 menu

The max function

The max function allows you to select the maximum of passed values. The function takes two or more values ​​as parameters, separated by commas, and returns the maximum of them.

Syntax

selector { property: max(value1, value2); }

Пример

Now the block width will be either 300px or 50% of the parent, whichever is greater:

<div id="parent"> <div id="child"></div> </div> #child { width: max(300px, 50%); height: 100px; margin: 0 auto; border: 1px solid red; } #parent { border: 1px solid green; }

:

See also

  • the min function
    that returns a minimum value
  • the calc function
    that calculates property values
byenru