CSS rem() Function
Example
Some rem() examples:
line-height: rem(9, 2); /* 1 */
line-height: rem(19, 4); /* 3 */
line-height:
rem(3.5, 3); /* 0.5 */
padding:
rem(9%, 2%); /* 1% */
padding: rem(19px, 4px); /* 3px */
padding: rem(19rem, 4rem); /* 3rem */
rotate: rem(120deg, 25deg); /* 20deg */
rotate: rem(120deg, -25deg); /*
-20deg */
rotate: rem(-90deg, 15deg); /* 5deg */
rotate: rem(-90deg,
-15deg); /* -5deg */
Definition and Usage
The CSS rem()
function returns the remainder
left over when a number (dividend) is divided by another number (divisor).
Example: rem(9, 2) = 1. (9 / 2 = 4; 4*2 = 8, remainder =1)
Example: rem(9, -2) = 1. (9 / -2 = 4; 4*-2 = -8, remainder =-1)
Note: The result always takes the sign of the divisor.
Version: | CSS4 |
---|
Browser Support
The numbers in the table specify the first browser version that fully supports the function.
Function | |||||
---|---|---|---|---|---|
rem() | 125 | 125 | 118 | 15.4 | 111 |
CSS Syntax
rem(dividend, divisor)
Value | Description |
---|---|
dividend | Required. The value (number, percentage, or dimension) that will be divided by divisor |
divisor | Optional. The divisor (number, percentage, or dimension) |
Related Pages
CSS reference: CSS acos() function.
CSS reference: CSS asin() function.
CSS reference: CSS atan() function.
CSS reference: CSS atan2() function.
CSS reference: CSS calc() function.
CSS reference: CSS cos() function.
CSS reference: CSS exp() function.
CSS reference: CSS hypot() function.
CSS reference: CSS log() function.
CSS reference: CSS mod() function.
CSS reference: CSS pow() function.