🍋
Menu
CSS

Calc

CSS calc() Function

A function for performing arithmetic calculations with mixed units in CSS property values (e.g. calc(100% - 2rem)).

Chi tiết kỹ thuật

CSS calc is part of the CSS specification maintained by the W3C CSS Working Group. Browser rendering engines (Blink, WebKit, Gecko) implement the specification through their layout and paint pipeline stages. Understanding the rendering pipeline — Style → Layout → Paint → Composite — is key to writing performant CSS. Properties that trigger layout recalculation (width, height, margin) are more expensive than those that only trigger compositing (transform, opacity).

Ví dụ

```css
/* Example: Calc */
.element {
  /* Apply calc to this element */
  display: block;
  margin: 0 auto;
}
```

Định dạng liên quan

Công cụ liên quan

Thuật ngữ liên quan