Skip to content
Advertisement

What is 100% in calc function

Within the css calc() function, what does 100% refer to and what is the equivalent code in JavaScript?

#div1 {
   width: calc(100% - 100px);
}

JSFiddle: https://jsfiddle.net/xoufnm6v/

Advertisement

Answer

100% refers to 100% of the width of the parent element. This calculation gives the current element a width 100 pixels narrower than it’s parent.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement