is a rather ambiguous description of the problem, and this is only a guess.
background CSS property - CSS | MDN
The property is a shorthand that sets the following properties in a single declaration:
background-clip,background-color,background-image,background-origin,background-position,background-repeat,background-size, andbackground-attachment.As with all shorthand properties, any omitted sub-values will be set to their initial value.
In other words, by using the shorthand property instead of only the background-color property there is a chance that another property is reverting to its initial value interfering with the desired change.
My best guess, however, is that there is other CSS with more specificity and the class selector you are using is less specific and being over-ridden.
The best way to diagnose the problem would be to use the browsers developer tools to see what CSS is involved with the display.