[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/CSS/Reference/Values/calc [Back]  [Original]

calc() - CSS: Cascading Style Sheets | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

calc()

Baseline Widely available *

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

* Some parts of this feature may have varying levels of support.

calc() CSS CSS . <length>, <frequency>, <angle>, <time>, <percentage>, <number>, <integer> .

In this article

css
/* property: calc(expression) */
width: calc(100% - 80px);

calc() , . , .

+

.

-

.

*

. <number> .

/

. <number> .

<length> , . .

  • 0 HTML .
  • + - . calc(50% -8px) , calc(50% - 8px) . , calc(8px + -50%) .
  • * / , .
  • , , / , auto .
  • calc() calc() .

<calc()> = 
calc( <calc-sum> )

<calc-sum> =
<calc-product> [ [ '+' | '-' ] <calc-product> ]*

<calc-product> =
<calc-value> [ [ '*' | / ] <calc-value> ]*

<calc-value> =
<number> |
<dimension> |
<percentage> |
<calc-keyword> |
( <calc-sum> )

<calc-keyword> =
e |
pi |
infinity |
-infinity |
NaN
CSS Values and Units Module Level 4 . . .

calc() . 40 .

css
.banner {
  position: absolute;
  left: 40px;
  width: calc(100% - 80px);
  border: solid black 1px;
  box-shadow: 1px 2px;
  background-color: yellow;
  padding: 6px;
  text-align: center;
  box-sizing: border-box;
}
html
<div class="banner"> !</div>

calc() .

CSS .

css
input {
  padding: 2px;
  display: block;
  width: calc(100% - 1em);
}

#form-box {
  width: calc(100% / 6);
  border: 1px solid black;
  padding: 4px;
}

, 1/6 . , 1em calc() . HTML CSS .

html
<form>
  <div id="form-box">
    <label>  .</label>
    <input type="text" />
  </div>
</form>

CSS calc()

CSS calc() . .

css
.foo {
  --widthA: 100px;
  --widthB: calc(var(--widthA) / 2);
  --widthC: calc(var(--widthB) / 2);
  width: var(--widthC);
}

widthC calc( calc( 100px / 2) / 2) . .foo , calc() width calc( ( 100px / 2) / 2), 25px . calc() calc() .

calc() .

css
h1 {
  font-size: calc(1.5rem + 3vw);
}

.

Specification
CSS Values and Units Module Level 4
# calc-func


Web Proxy Viewer  |  New URL  |  Original Page