Hide without removing background image

student picture student · May 6, 2011 · Viewed 51.3k times · Source

Is there a way to hide the background image in CSS without removing it? For convenience, I'm using CSS to change whether or not it is displayed, and relying on a class to make it show. So, by default, it would be hidden, but the class would make it show. Because of this, the background image cannot be altered. What background properties can I use to achieve this? Changing the size to "0 0" actually made it 1px in the top left corner - not completely hidden. CSS3 solutions are accepted.

Answer

Tamás Pap picture Tamás Pap · Sep 28, 2014

Just met the same problem. I use:

background-size: 0 0;

I think it's a little bit friendlier than using some huuuuge negative values for background-position.