How to set background color to transparent?

时间:2016-04-07 10:31:11

标签: css html5 css3 transparent

I want to set the background-color of my header to transparent, but when I use background-color: transparent nothing happens.

When I use background-color:rgba(255,0,0,0.5), I get (255,127,127) in every browser.

Snapshot

How can I set the background-color to transparent?

Okay I think this could help:

In the Html its:

<!-- Header -->
        <div id="header" class="alt">
        <h1 id="logo">Christina Stephan</a></h1>
            <p>Schauspielerin - Sängerin - Sprecherin</p>
            <nav id="nav">
                <ul>
                    <li><a href="index.html">Startseite</a></li>
                    <li><a href="vita.html">Vita</a></li>
                    <li><a href="fotos.html">Fotos</a></li>
                    <li><a href="medien.html">Medien</a></li>
                    <li><a href="impressum.html">Impressum</a></li>
                </ul>
            </nav>
        </div>

So the CSS is:

#header {
    background: #fff
    border-bottom: solid 1px rgba(144, 144, 144, 0.25);
    box-shadow: 0px 0.0375em 0.125em 0px rgba(0, 0, 0, 0.05);
    color: #fff;
    cursor: default;
    height: 3.5em;
    letter-spacing: 0.11em;
    line-height: 4.6em;
    position: fixed;
    text-transform: uppercase;
    top: 0;
    width: 100%;
    z-index: 10000;
}

3 个答案:

答案 0 :(得分:3)

You can to the opacity property:

.transparent {
    opacity: 0;
}

You can also do it with the property background-color and the rgba() function. The last parameter represents the opacity, setting it to 0 will set the color to be transparent.

答案 1 :(得分:1)

you can use opacity to make color transparent .. set proper color first then do this

 {opacity:0}

答案 2 :(得分:1)

使用此(CSS):

background-color:transparent;