I was calculating margin with CSS root variable

:root {
  --hthumb:  30px;
  --htrack:  15px;
  --hthumbh: 35px
}

I was calculating the margin like this:

margin-top: ((var(--htrack) - var(--hthumb))/2)px Is it even possible?

This works:

:root {
  --hthumb:  30px;
  --htrack:  15px;
  --hthumbh: 35px
}
div{
  margin-top: calc((var(--htrack) - var(--hthumb))/2);
}
2 Likes

Yes.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.