r/csshelp • • May 28 '20

Resolved Does Reddit actually support 'var()' for subreddit stylesheets?

ok it's answered

yep looks like it doesn't support 'var()'

(thanks, u/nekosune!)


the tl;dr version

  • Does reddit actually support 'var()'?

  • And, if it is supported, what am I doing wrong?


the long version

On r/worldpolitiCSSarea (yes, worldpolitiCSS was taken several years ago, and I know that the admins won't grant it for CSS testing via redditrequest), I'm trying out some stuff to allow header banners to be changed, and it currently works as intended.

So, for ease of maintainability, I was attempting to implement some var() stuff, so, if banners get added/removed, or if we wanted to change the time spent between banners changing, instead of needing to recalculate all the keyframe times/total animation length/etc, we could just change the values held by the variables, solving that problem for us.

So, I attempted to define some variables as follows:

:root{
    /* setting some custom variables */
    
    /* replace this with the number of banners being used */
    --banner-count:6;
    
    /* replace this with the time to wait on each banner */
    --banner-delay:30s; 
}

and then, within the #header tag, I tried to access them as follows:

animation-duration: calc( var(--banner-count) * var(--banner-delay) );
animation-delay: calc( var(--banner-delay) / 2);

(didn't get around to attempting the keyframe stuff just yet)

and then, upon pressing 'preview', I was greeted with

syntax error: Expected <ident> for declaration name, got literal.

for the variable definitions, and

unknown function "var" 

for when I was trying to access them.

So, as I couldn't find any answers about whether or not reddit actually supports 'var()', or if I'm just doing something wrong, I'm asking for help here. (if nothing else, it might be useful for the next person who finds themselves in this situation).

  • Does reddit actually support 'var()'?

  • And, if 'var()' is supported, what am I doing wrong?

8 Upvotes

3 comments sorted by

2

u/[deleted] May 28 '20

Reddit's CSS is quite limited, I believe var is one of the things not implemented. they only allow an older, limited version for security sadly.

1

u/loomynartylenny May 28 '20

feck

welp, that answers that question.

2

u/RandommUser May 28 '20

I doubt it supports them