0

I am trying to do something like in in sass:

provider-details {
        position: absolute;
        top: calc( #{$speciality-widget-top-offset} + #{$speciality-n-provider-details-gap} + #{attr(data-speciality-widget-height)});
        left: auto;
        right: $provider-details-right-offset;
        bottom: $providers-details-bottom-offset;
        max-height: 715px;
    }

I tried this too:

top: $speciality-widget-top-offset + $speciality-n-provider-details-gap + attr(data-speciality-widget-height);

but nothing is working. is there a way to calculate top with css attr() function in sass?

Sushmit Sagar
  • 1,412
  • 2
  • 13
  • 27

1 Answers1

0

so issue you have is that attr(...) inside calc is invalid CSS (might change later on in CSS4 as per this SO answer)

A workaround would be to change your html to replace your data attribute with an inline css variable like this:

<div style="--speciality-widget-height: 2">

and use it like this:

top: calc(#{$speciality-widget-top-offset} + #{$speciality-n-provider-details-gap} + var(--speciality-widget-height));
Apolo
  • 3,844
  • 1
  • 21
  • 51