Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

round

Description

The round function for CSS contains an optional rounding strategy, and two calculations A and B, and returns the value of A, rounded according to the rounding strategy, to the nearest integer multiple of B either above or below A.

Syntax

CSS

round()

Values

<round()> =
    round(
        <rounding-strategy>?,
        <calc-sum>,
        <calc-sum>
    )
<rounding-strategy> =
    nearest |
    up |
    down |
    to-zero
nearest

Choose whichever of lower B and upper B that has the smallest absolute difference from A. If both have an equal difference (A is exactly between the two values), choose upper B.

up

Choose upper B.

down

Choose lower B.

to-zero

Choose whichever of lower B and upper B that has the smallest absolute difference from 0.

<calc-sum> =
    <calc-product>
    [ [ '+' | '-' ] <calc-product> ]*
<calc-product> =
    <calc-value>
    [ [ '*' | '/' ] <calc-value> ]*
<calc-value> =
    <number> |
    <dimension> |
    <percentage> |
    <calc-constant> |
    ( <calc-sum> )
<number>

An integer or zero or more decimal digits followed by a dot (.) followed by one or more decimal digits. The first character may be preceded by a sign (- or +). The last character may be succeeded by an exponent (e or E) and an integer.

<dimension>

A number with a unit.

<percentage>

Specifies the percentage using a number followed by a percent sign (%).

<calc-constant> =
    e |
    pi |
    infinity |
    -infinity |
    NaN
e

The base of the natural logarithm, approximately equal to 2.7182818284590452354.

pi

The ratio of a circle's circumference to its diameter, approximately equal to 3.1415926535897932.

infinity

Positive infinity.

-infinity

Negative infinity.

NaN

Not a number.

*

Multiplication.

/

Division.

+

Addition.

-

Subtraction.

Examples

1 · nearest

2 · up

3 · down

4 · to-zero

5 · JS

mod

rem

abs

acos

asin

atan

atan2

attr

calc

clamp

color

conic-gradient

cos

counter

counters

hsl

hsla

hwb

lab

lch

linear-gradient

matrix

matrix3d

max

min

mod

oklab

oklch

param

perspective

radial-gradient

rem

repeating-conic-gradient

repeating-linear-gradient

repeating-radial-gradient

rgb

rgba

rotate

rotate3d

rotateX

rotateY

rotateZ

scale

scale3d

scaleX

scaleY

scaleZ

sin

skew

skewX

skewY

src

tan

translate

translate3d

translateX

translateY

translateZ

url

var

World Wide Web Consortium (W3C)

HomeMenu