someone
someone

Reputation: 104

CSS Override background without changing or restoring background image

When I try in stylish(chrome) *{ background : black !important } all the background images are overridden,

I was wondering if there is a way to restore the background images or keep them intact.

Thanks

Upvotes: 1

Views: 693

Answers (1)

Ehsan
Ehsan

Reputation: 12959

Use background-color instead of background

*:not([background-image]) {
  background-color:black!important;
}

div {
  width: 200px;
  height: 200px;
  background-color: red;
}

.bg {
  background-image: url('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTqy1uodNithL90ttojytSP2imO4RC1y3qlm_ebZdRmNWh_8juV9Q');
}

*:not([background-image]) {
  background-color:black!important;
}
<div>I am Test</div>
<div class="bg">I am Test2</div>

Upvotes: 2

Related Questions