minify icon indicating copy to clipboard operation
minify copied to clipboard

CSS variables with default values lose their units which makes calculations that they participate in invalid

Open rinart73 opened this issue 1 year ago • 2 comments

CSS variables default values shouldn't have their units removed because they might be used in calc expressions. CSS calc is very sensitive to units and quite often if the units are not specified, the whole expression becomes invalid.

Input:

html {
  --admin-bar-fixed:var(--wp-admin--admin-bar--height, 0px);
  scroll-padding: calc(var(--admin-bar-fixed) + 60px) 0px 0px 0px;
}

Output (calc becomes invalid because it's now trying to 0 + 60px):

html{--admin-bar-fixed:var(--wp-admin--admin-bar--height,0);scroll-padding:calc(var(--admin-bar-fixed) + 60px) 0 0 0;}

Expected output (calc is valid 0px + 60px):

html{--admin-bar-fixed:var(--wp-admin--admin-bar--height,0px);scroll-padding:calc(var(--admin-bar-fixed) + 60px) 0 0 0;}

rinart73 avatar Mar 16 '23 13:03 rinart73

Hi,

I can confirm this issue, too.

PrestaEdit avatar Jul 07 '23 09:07 PrestaEdit

Seems like this is fixed. I get the following output: html{--admin-bar-fixed:var(--wp-admin--admin-bar--height, 0px);scroll-padding:calc(var(--admin-bar-fixed) + 60px) 0 0 0}

topfuel75 avatar Mar 27 '24 13:03 topfuel75