问题描述:

I have the following css and html. I'm trying to hide the background of an image so that you just see the image without its surrounding white space. Note: I'm a noobie with css so please be gentle. lol

 

.boxcontainer {

font-size: 12px;

position: absolute;

left: 100px;

top: 20px;

width: 300px;

z-index: 1000;

}

.boxwithicon

{

background: transparent;

background-position: 5px 10px;

background-repeat: no-repeat;

padding-left: 50px;

}

.boxstatus {

-moz-border-radius: 10px 10px 10px 10px;

background-color: rgba(0, 0, 0, 0.4);

border: 3px solid #000000;

color: #FFFFFF;

/*margin-bottom: 5px; */

padding: 15px;

position: relative;

}

HTML:

<div class="boxcontainer">

<div id="head1" ><b><u>Test</u></b></div>

<div class="boxstatus boxwithicon">

<img src="images/smrsfolderopen.png" alt=""><a href="http://localserver/page">Customers</a>

</div>

</div>

So what I'm getting is my image with white background showing in image block. Just like with any image you have white space around actual image. I don't want that to show up. Hopefully i'm explaining this properly.

-DND

I think we are all on the same page. Now when i explorer other websites that use images they do have white backgrounds as well when I check out the image itself but when displayed on website its transparent. For instance check out this site: link text and click on Simple Example button. you will see icon next to text in box. How are they making the white background be transparent?

Thanks

网友答案:

Assuming you have an image with a white background, I would open up the png in photoshop and delete the background layer, and then make it a transparent png. That way, the background behind the image will come through.

网友答案:
    .boxcontainer {
     background: transparent;// you actually want to make sure you're not overriding this in any other elements further up the DOM
    font-size: 12px;
    position: absolute;
    left: 100px;
    top: 20px;
    width: 300px;
    z-index: 1000;
}

.boxwithicon 
{
    background: transparent;
    background-position: 5px 10px;
    background-repeat: no-repeat;
    padding-left: 50px;
}

.boxstatus {
    -moz-border-radius: 10px 10px 10px 10px;
    background: transparent;// and NOT a set color. that would make it NOT be transparent...
    border: 3px solid #000000;
    color: #FFFFFF;
    /*margin-bottom: 5px; */
    padding: 15px;
    position: relative;

}
网友答案:

You need to edit your image and make the background transparent.

Note that it will not work in IE6, unless you use a filter.

网友答案:

Png files have the ability to have transparency. But that doesn't mean that the image has any transparency set. I'd first check the image to see what's up.

Aside from that I don't see anything that would cause the whitespace... There doesn't seem to be any styles in your code above targeting the image itself.

Feel free to follow up with questions, and I'll be happy to help you troubleshoot.

相关阅读:
Top