Questions tagged [css-calc]

calc() is a native CSS way to do simple math right in CSS as a replacement for any length value (or pretty much any number value). It has four simple math operators: add (+), subtract (-), multiply (*), and divide (/).

The calc() CSS function can be used anywhere a <length>, <frequency>, <angle>, <time>, <number>, or <integer> is required. With calc(), you can perform calculations to determine CSS property values.

It is possible to nest calc() function, the internal ones being considered as simple parenthesis ().

Syntax

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

Expressions

The expression can be any simple expression combining the following operators, using standard operator precedence rules:

+ Addition.

- Subtraction.

* Multiplication. At least one of the arguments must be a <number>.

/ Division. The right-hand side must be a <number>.

The operands in the expression may be any length syntax value. You can use different units for each value in your expression, if you wish. You may also use parentheses to establish computation order when needed.

You can see a couple of use cases for calc()

214 questions
0
votes
1 answer

Android and IOS Calc() tag problems

Hello I have problems with the Calc() tag on both Safari for IOS and the standard Android browser. The site got a fixed width and height unless the Calc() tag is supported. Chrome -> Calc supported no problem Safari Mac -> Calc not supported fixed…
H3AP
  • 1,058
  • 1
  • 10
  • 16
0
votes
1 answer

Media Query not overriding webkit calc

I have a calc definition: #navigation-panel { a, i.navEmptyBlock { // ... width: -webkit-calc(12% - 2px); width: -moz-calc(12% - 2px); width: -o-calc(12% - 2px); width: -ms-calc(12% - 2px); …
jviotti
  • 17,881
  • 26
  • 89
  • 148
-1
votes
1 answer

Set dynamic width by using calc() doesn't work

I have three child elements which should have an exact width of 1/3 of the parent element. I used calc() but the third child element is not in line... any idea? ul { background:yellow; color:black; } ul li { width:calc(100% / 3); …
didi
  • 287
  • 1
  • 6
  • 16
-2
votes
2 answers

How do I base a CSS property on another element that isn't the direct parent?

For example, I would like to make 3 div columns which are 5%, 15% and 25% the width of the page (body), respectively. Pseudo-Code (HTML):
Pseudo-Code…
FluorescentGreen5
  • 879
  • 11
  • 23
1 2 3
14
15