3

I have 2 .png pictures with a transparent background. I would like to add them to my page, at the moment I use

<div class="thumbnail">
    <img src="foo.png">
</div>

but when I open the page (through chrome) the background color is white, and I don't want it white, I want it to be transparent.

I would like not to use CSS, but if there is no other option so I'll do it.

4
  • Are you sure the image just isn't showing the page background through it... Commented Jun 23, 2015 at 9:46
  • I don't think so it will be possible without CSS. You can add the following code in your css if you want, it will do the job ` .thumbnail,.foo { background-color: transparent}` Commented Jun 23, 2015 at 9:48
  • 2
    I think you are using bootstrap, and .img-thumbnail have default background: #fff Commented Jun 23, 2015 at 9:50
  • I am using bootstrap. Is it possible through the bootstrap class to make the background transperent Commented Jun 23, 2015 at 11:24

1 Answer 1

4

Please note that, if you are not giving any colours for the background, then by default it will be white on most browsers! If you are using chrome, you can do like this:

body {
  background: url("transparent1.png") transparent,
              url("transparent2.png") transparent;
}

As said in the comment by KittMedia, if you are targetting new browsers, replace transparent with:

body {
  background: url("transparent1.png") rgba(0, 0, 0, 0),
              url("transparent2.png") rgba(0, 0, 0, 0);
}

This way, you can overlay two images and keep them transparent too. Is this what you are expecting?

Sign up to request clarification or add additional context in comments.

2 Comments

transparent is deprecated and should be replaced with rgba(0, 0, 0, 0) if you don't need to support older browsers.
yeah, it didnt work, both of the options (transperent and rgba)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.