Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override CSS Background that already has !important?

Tags:

css

stylish

I am trying to override a website's background with Stylish but it isn't working. The background css for the website also has an !important, and it is overriding Stylish.

My code:

body {
  background-image: none !important; 
  background: black !important;
}
like image 353
Enoch Avatar asked May 01 '14 20:05

Enoch


People also ask

How do you overwrite background color in CSS?

If that class has a background-color of blue, and you want your <div> to have a red background instead, try to change the color from blue to red in the class itself. You could also create a new CSS class that defined a background-color property with a value of red and let your <div> reference that class.


1 Answers

You'll need to be more specific (quick guide to CSS specificity), for instance, using the > selector:

body {
  background-image: none !important; 
  background: black !important;
}

html > body {
  background-image: none !important; 
  background: red !important;
}

JSBin

like image 188
SomeKittens Avatar answered Sep 21 '22 16:09

SomeKittens