cssbackgroundlightbox

Background Color Error


So I am attempting to make a really simple lightbox that I can use for something, however for whatever reason the div thats supposed to darken the background is canceling out any background attribute.

HTML

<div class="zoom-placeholder">
    <div class="zoom-container">
        <img class="zoom" src="image.png" />
    </div>
</div>

CSS

.zoom {
    margin: 1em 0em; padding: 1em;
    background: #f9f9f9;
    border: 1px solid #ccc; border-bottom-width: 2px;
    box-shadow: rgba(0,0,0,0.075) 0px 2px 3px, inset rgba(255,255,255,0.5) 0px 0px 25px;
    user-select: none;
    user-drag: none;
}
.zoom-container, .zoom-placeholder {display:table-cell}
.zoom-container.open {
    position: fixed;
    z-index: 999;
    width: 100%; height: 100%;
    top: 0px; bottom: 0px;
    left: 0px; right: 0px;
    background: rgba(0,0,0,0,0.5); /* <--- Not Working --- */
}
.zoom-container.open .zoom {
    width: auto;
    height: auto;
    position: absolute;
    margin: 0em;
    border-color: rgba(0,0,0,0.1);
    box-shadow: rgba(0,0,0,0.5) 0px 10px 30px, inset rgba(255,255,255,0.5) 0px 0px 25px;
}

There isn't anything I have that's writing it over but its still not displaying correctly.

You can see this in use here:

http://jsfiddle.net/JamesKyle/8H7hR/34/


Solution

  • Look at the CSS background: rgba(0,0,0,0,0.5); /* <--- Not Working --- */ is not working because that's invalid CSS3 should be background: rgba(0,0,0,0.5);
    Notice the missing 0 you had 1 too many. R ed, G reen, B lue, A lpha transparency. :]