1

I have this css rule:

#SideBar{
height: calc(100vh, -82px);
overflow: auto;
/*Something more*/
}

The problem is that, in all the other browser like: IExplorer, Chrome, Opera, Firefox, but in Safari is not working this rule? Exist an alternative rule to set the height?

Benjamin RD
  • 11,516
  • 14
  • 87
  • 157

2 Answers2

5

The proper syntax of CSS calc() function is -

calc(expression)

Where the expression can be built using +, -, * or / operators.
The comma , is not a valid operator to use inside calc(). Thus you are having an invalid property value of height inside the #SideBar.

Even you have to add space between operators and values.
You are having no space between - sign and 82px

So, your final code should looks like this -

#SideBar{
    height: calc(100vh - 82px);
    overflow: auto;
    /*Something more*/
}

Also safari still has some issue with viewport units, see here. You might want to use percentage value instead of viewport units. In this case the code will be -

#SideBar{
    height: calc(100% - 82px); /* Fallback for safari */
    height: calc(100vh - 82px); /* Supports for Chrome, FireFox, IE10+ */
    overflow: auto;
    /*Something more*/
}
Community
  • 1
  • 1
aniskhan001
  • 7,981
  • 8
  • 36
  • 57
2

Try without comma there or with -webkit-calc () prefix

ondObno
  • 91
  • 5