CSS Variables in the Service Portal

darren_halliday
ServiceNow Employee
ServiceNow Employee

Hi there,

I have created a CSS variable in the Stock theme record in the Service Portal as follows: "$my-color: #990010;".   Screen Shot 2017-04-24 at 3.59.25 PM.png

From a CSS sheet attached to the theme I declare the following rule:

Screen Shot 2017-04-24 at 4.05.57 PM.png

This does not work in widget on the portal page.   If however, I change the CSS1 rule to "color: #990010;" then it does change my widget.   Can any spot the error in my variable call from the CSS rule?

Darren

3 REPLIES 3

edbailey
Giga Contributor

Is it because the brand variables are not called from CSS style sheets that you create but directly from css section of the widget editor?


arthurcheung
Kilo Expert

I once had same symptoms when I had a slight typo in my variable declaration:



$aqua: #001d1c1 !default;



Where it should have been:



$aqua: #00d1c1 !default;



The syntax in your variables looks correct though. So only thoughts are to try removing all the other variables except for "$my-color" and see if it works. If it does, then your CSS might be breaking because of another variable further up.


Ryan Magsam
Kilo Contributor

I was able to resolve this by moving my class definition that called the variable from the CSS Include for the theme to the widget specific CSS (a header widget in my case).



We're on Kingston, if it makes any difference.