Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide without removing background image

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.

like image 294
student Avatar asked May 06 '11 16:05

student


People also ask

How can I hide my photo background?

Select the picture that you want to remove the background from. Under Picture Tools, on the Format tab, in the Adjust group, select Remove Background.

How do I hide part of a photo?

You can use the max-height property to specify the maximum height of the image, and then use overflow: hidden; to hide anything else.

How do I remove the background from a PNG image in CSS?

Option 1: Pure CSS [Limited Support]By putting the blend mode to screen you can remove the white background of your png image.


2 Answers

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.

like image 139
Tamás Pap Avatar answered Oct 26 '22 23:10

Tamás Pap


You could try positioning the background image outside of the viewable area, like setting

background-position: -9999px -9999px

or something less drastic depending on the viewable area.

like image 21
Paul Sham Avatar answered Oct 27 '22 01:10

Paul Sham