Looking to create a smooth fade in and out effect for my lightbox using CSS and a bit of JavaScript. I've managed to achieve the fading in part, but now I'm wondering how to make it fade out as well.
Here is the CSS code:
@-webkit-keyframes FadeIn {
0% {
opacity:0;
}
10% {
opacity:0.1;
}
}
.overlay {
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
-moz-opacity: 0.1;
opacity:.10;
background: #000;
filter: alpha(opacity=10);
z-index:1001;
-webkit-animation-name: FadeIn;
webkit-animation-timing-function: ease-in-out;
-webkit-animation-duration: 8s;
}
.lightbox {
background: #FFF;
width: 640px;
padding: 20px;
position: absolute;
left: 30%;
top: 20%;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Helvetica, Arial, sans-serif;
font-size: 13px;
color: #786c6d;
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
z-index:1002;
-webkit-animation-name: FadeIn;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-duration: 1s;
}
And here is the HTML:
<a href="javascript:void(0)" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">Start slideshow</a>
<div id="light" class="lightbox">
<img src="http://farm8.staticflickr.com/7169/6765756923_bb4252c86f_z.jpg" alt="" width="640" height="426" />
<br>
<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></div>
<div id="fade" class="overlay"></div>