【发布时间】:2021-12-09 04:56:38
【问题描述】:
我正在尝试在 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;
}
我也试过这个:
top: $speciality-widget-top-offset + $speciality-n-provider-details-gap + attr(data-speciality-widget-height);
但没有任何效果。有没有办法用sass中的css attr()函数计算top?
【问题讨论】:
-
它有什么问题?
-
用 sass 插值我得到了这个
calc( 30px + 15px + attr(data-speciality-widget-height, px)) -
这与第二种方法
45pxattr(data-speciality-widget-height)作为输出 -
啊,我明白了,很遗憾这是无效的 css。您目前不能在 calc 中使用 attr 函数。这可能是 CSS4 中的一个东西