CSS背景颜色透明度

Jos*_*ley 0 html css transparency

我试图设置a的透明度<div>只影响背景颜色,但每次我这样做,它最终会使整个<div>透明.这是我的CSS,也是一个小提示:

html {
        background-image: url("https://dl.dropboxusercontent.com/u/47991825/8856597-daisies-green-background.jpg");
    }
    .profilePic {
        width: 128px;
        height: 128px;
        border-radius: 64px;
        -webkit-border-radius: 64px;
        -moz-border-radius: 64px;
    }
    h1 {
        font-family: 'Open Sans', sans-serif;
        font-weight: bold;
    }
    #mainCont {
        width: 250px;
        margin: auto;
        position: absolute;
        top: 0; left: 0; bottom: 0; right: 0;
        padding: 15px;
        border: 1px solid #000000;
        height: 40%;
        font-family: 'Open Sans', sans-serif;
        font-weight: normal;
        font-size: 12pt;
        background-color: #000000;
        opacity: 0.4;
    }
    #footer {
        position: absolute;
        bottom: 0;
        height: 40px;
        margin-top: 40px;
    }
    ul {
        list-style-type: none;
        padding: 0;
    }
    a:link {
        text-decoration: none;
    }
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/joshrlangley/ne2o1r5x/1/

Rud*_*die 5

(背景)颜色具有rgba(r, g, b, opacity)格式.

#mainCont {
    // 0, 0, 0 = black
    // 255, 255, 255 = white
    background-color: rgba(0, 0, 0, 0.4);
}
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/rudiedirkx/ne2o1r5x/2/

遗憾的是,背景图像仍然没有不透明度选项.