siannone
siannone

Reputation: 6763

Transparent png as background-image

I'm having some issues while using a transparent PNG image as a background image via CSS.

This is what I get: https://i.sstatic.net/BKj7E.png

And this is my CSS code:

#userBar {
    background-color: transparent;
    background-image: url('../img/userbarbg.png');
    background-position: bottom;
    background-repeat: repeat-x;
    float: left;
    height: 36px;
    margin-top: 10px;
    width: 100%;
    box-shadow: 0 0 5px #888;
}

Am I doing something wrong?

Upvotes: 3

Views: 21454

Answers (1)

Noah Witherspoon
Noah Witherspoon

Reputation: 57149

You’re seeing the box-shadow behind the background image. The element is still a rectangular box as far as the browser is concerned, so that box shape is what it uses to generate the shadow. You’ll need to specify a border-radius (including the various browser prefixes, -webkit-, -moz-, -o-, etc.) that matches that of the corners on your transparent background so the shadow will have the same shape as the content it's behind.

Upvotes: 1

Related Questions