3

I have the following inline-styling using Angular's ng-style and css's "calc()', but it didn't work. Can anyone tell me what's wrong?

// my jade file has a class named '.logo-area'. 
.logo-area(ng-style="{'right':'calc(100% -'+({{fixedWidth}}+'px') +')'}")
zihaow
  • 312
  • 2
  • 9
  • 23
  • 3
    Looks like you would need to leave an extra space after the minus sign at least. – Shikkediel Oct 14 '15 at 20:55
  • Right. the [MDN](https://developer.mozilla.org/en/docs/Web/CSS/calc) page on calc mentions this specifically: "The operand of `calc(50% -8px)` for instance will be parsed as a percentage followed by a negative length, an invalid expression" – Mr Lister Oct 14 '15 at 21:04

2 Answers2

5

This worked for me in HTML with Angular 8

[ngStyle]="{'width': someAngularVariable +'px', 'left': 'calc(100% - ' +someAngularVariable + 'px)' }"
Krishna Sagar
  • 179
  • 1
  • 3
2
.logo-area(ng-style="{'right': 'calc(50% - '+{{fixedWidth}}+'px'+')'}")

Will solve the problem.

gofr1
  • 15,741
  • 11
  • 42
  • 52
zihaow
  • 312
  • 2
  • 9
  • 23