cos() CSS Function
The cos() function returns the cosine of an angle, a number between -1 and 1, useful for placing items in a circle.
Description
The cos() CSS function calculates the cosine of an angle. The argument is an <angle> or a plain number (radians), and the result is a <number> between -1 and 1. For example, cos(0deg) is 1, cos(60deg) is 0.5 and cos(90deg) is 0.
Cosine gives the horizontal position of a point on a circle. Used together with sin(), which gives the vertical position, it lets you arrange elements in a circle, such as a radial menu, clock numbers or icons around an avatar. Each item only needs an angle, and the coordinates are calculated by the browser.
The cos() function is one of the CSS trigonometric functions, together with sin(), cos(), tan(), asin(), acos(), atan() and atan2(). Like calc(), it can be used anywhere a value of the matching type is accepted, and its arguments can contain full calculations, custom properties and the constants pi and e.
.ring {
--radius: 90px;
position: relative;
}
/* Place each item around a circle */
.ring .item {
position: absolute;
left: calc(50% + cos(var(--angle)) * var(--radius));
top: calc(50% + sin(var(--angle)) * var(--radius));
translate: -50% -50%;
}
Interactive Demo
Syntax
cos() = cos( <calc-sum> )
Values
- <calc-sum>A calculation resolving to an <angle> or a <number> (interpreted as radians). The function returns a <number> from -1 to 1.
Example
Browser Support
The following information will show you the current browser support for the CSS cos() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





