Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rem() - New CSS functional notation #23183

Merged
merged 16 commits into from
Jan 4, 2023
19 changes: 10 additions & 9 deletions files/en-us/web/css/rem/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ browser-compat: css.types.rem

{{CSSRef}}{{SeeCompatTable}}

The **`rem()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) returns a remainder (with the same sign as the dividend) when dividing one number by another. The remainder is a left over when one operand is divided by a second operand. It always takes the sign of the dividend.
The **`rem()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) returns a remainder (with the same sign as the dividend) when dividing one number by another. The remainder is a leftover when one operand is divided by a second operand. It always takes the sign of the dividend.
ramiy marked this conversation as resolved.
Show resolved Hide resolved

> When dividing 12 by 5, the result is 10 with a remainder of 2. The full calculation is `12 / 5 = 10 (2)`. The `rem()` function returns the reminder.
> When dividing 27 by 5, the result is 25 with a remainder of 2. The full calculation is `27 / 5 = 5 * 5 + 2`. The `rem(27, 5)` function returns the remainder of `2`.
ramiy marked this conversation as resolved.
Show resolved Hide resolved

## Syntax

```css
/* Unitless values */
/* Unitless <number> */
line-height: rem(21, 2); /* 1 */
line-height: rem(14, 5); /* 4 */
line-height: rem(5.5, 2); /* 1.5 */

/* Unit based values */
margin: rem(14%, 3%); /* 2% */
margin: rem(18px, 5px); /* 3px */
margin: rem(25vmin, 7vmin); /* 4vmin */
/* Unit based <percentage> and <dimension> */
margin: rem(14%, 3%); /* 2% */
margin: rem(18px, 5px); /* 3px */
margin: rem(10rem, 6rem); /* 4rem */
margin: rem(26vmin, 7vmin); /* 5vmin */
ramiy marked this conversation as resolved.
Show resolved Hide resolved

/* Negative/positive values */
rotate: rem(200deg, 30deg); /* 20deg */
Expand All @@ -42,7 +43,7 @@ rotate: rem(-55deg, -15deg); /* -10deg */

### Parameter

The `rem(dividend, divisor)` function accepts two comma-separated values as its parameters. Both parameters must have the same type, or else the function is invalid.
The `rem(dividend, divisor)` function accepts two comma-separated values as its parameters. Both parameters must have the same type for the function to be valid.
ramiy marked this conversation as resolved.
Show resolved Hide resolved

- `dividend`
- : A calculation that resolves to a {{CSSxREF("&lt;number&gt;")}}, {{CSSxREF("&lt;dimension&gt;")}}, or {{CSSxREF("&lt;percentage&gt;")}} representing the dividend.
Expand All @@ -52,7 +53,7 @@ The `rem(dividend, divisor)` function accepts two comma-separated values as its

### Return value

Returns a {{CSSxREF("&lt;number&gt;")}}, {{CSSxREF("&lt;dimension&gt;")}}, or {{CSSxREF("&lt;percentage&gt;")}} (the same type as the parameters) representing the remainder, that is, the operation left over.
Returns a {{CSSxREF("&lt;number&gt;")}}, {{CSSxREF("&lt;dimension&gt;")}}, or {{CSSxREF("&lt;percentage&gt;")}} (corresponds to the parameters' type) representing the remainder, that is, the operation leftover.

- If `divisor` is `0`, the result is `NaN`.
- If `dividend` is `infinite`, the result is `NaN`.
Expand Down